Doing some test-driven refactoring