Adding unit tests to work out what's wrong.