Refactoring worker and tests