AR 4.0 and test fixes

This change fixes an issue where newly created records do not fetch the returned sequence values correctly if one or more of the primary keys is generated by a sequence.

I've also fixed the test suite and eliminated the majority of the deprecation warnings.