Refactored and wrote more tests
Extracted mocks to a module