Rewrite mongoose helper, add tests for it