CMCache unit tests and associated bugfixes