Using unittest.mock for mocks
Refactoring