refactoring and CM tests