Refactored code using TDD.