Finished the initial refactoring using TDD approach