Remove singleton classes on CPK relations

Extract CPK methods to its own module and extending instead of opening the singleton class. This fixes `Marshal.dump` so caching relations works again.

I also removed some deprecation warnings on the AR::Base classes (on scopes) and fixed the broken test on MySQL.

This is similar to #169 but works with Rails 4.