cm tests and refactoring