CPK Refactoring, added tests