Refactoring with tests.