The following is a TDD Kata – an exercise in coding, refactoring and test-first.