Refactoring from unit test