(#2555) - fix 'change' event for db.sync()

This ought to fix it. I also added some tests to ensure we're not leaking any listeners. Apparently calling `removeAllListeners` in `cleanup` is unnecessary, because that gets taken care of in `completeReplication` anyway.
this gets called in `completeReplication` anyway. I also added a test that confirms we're not leaking any listeners. The tests fail if you remove this line and the other `removeAllListeners`.