An exercise in refactoring legacy code so that it's testable and covered