Refactoring so all test can pass