Fix tests for 2.2.6, 2.4.9, and 2.5.x

This incorporates #572, which was merged to v1.4, and an overall merge of v1.4 to master. Merge conflicts were primarily to do with #566, which was previously merged to master.

I added an additional commit after the v1.4 merge, and ensured compatibility with MongoDB 2.2.6, 2.4.9, and 2.5.x in a PHP 5.5 build.