Fix lots of integration tests by introducing TestMatrix class and MatrixWorkerFactory.