fix issue #653

Fixes the issue #523, but requires all custom methods toBson() to be const.