PHP-1272 et al: Add missing bson_encode() tests and fix segfaults

 * https://jira.mongodb.org/browse/PHP-1272
 * https://jira.mongodb.org/browse/PHP-1273
 * https://jira.mongodb.org/browse/PHP-1277
The scope document is redundant here (see: [PHP-897](https://jira.mongodb.org/browse/PHP-897)). Not to be fixed in this PR though.