Refactor so this actually works.
Refactor tests. Fixed typo in ca.pp