Edit some functions in cp.py and test_cp.py