Restructured the code to make it testable.
Added more tests for the mps_worker.