Some improvements to unit tests, which need much work.