Some cleaning-up and a new unit test