More unit tests and a bit of clean-up.