cleanup and add tests, worker