function testPostUpdateState (cb) {
        d.find({}, function (err, docs) {
          var doc1 = _.find(docs, function (d) { return d._id === id1; })
            , doc2 = _.find(docs, function (d) { return d._id === id2; })
            , doc3 = _.find(docs, function (d) { return d._id === id3; })
            ;

          docs.length.should.equal(3);

          Object.keys(doc1).length.should.equal(2);
          doc1.somedata.should.equal('ok');
          doc1._id.should.equal(id1);

          Object.keys(doc2).length.should.equal(2);
          doc2.newDoc.should.equal('yes');
          doc2._id.should.equal(id2);

          Object.keys(doc3).length.should.equal(2);
          doc3.newDoc.should.equal('yes');
          doc3._id.should.equal(id3);

          return cb();
        });
      }
Complicated behavior here. Basically we need to test that when a user function throws an exception, it is not caught
in NeDB and the callback called again, transforming a user error into a NeDB error.

So we need a way to check that the callback is called only once and the exception thrown is indeed the client exception
Mocha's exception handling mechanism interferes with this since it already registers a listener on uncaughtException
which we need to use since findOne is not called in the same turn of the event loop (so no try/catch)
So we remove all current listeners, put our own which when called will register the former listeners (incl. Mocha's) again.

Note: maybe using an in-memory only NeDB would give us an easier solution