BSON: Add tests which make sure memory is allocated and deallocated precisely when it should be

These cases are designed to test the memory allocation behaviors in pull requests #93 and #96.