Dry

This is actually builds on top of pull request https://github.com/namlook/mongokit/pull/123

It had some code copied three times so I figured that we'd refactor for DRYness.