(#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.
I have no idea what this code does. When I tried to explain it to myself in English, it sounded like Dada poetry: "when the new listener's event is a removeListener, there's no need to assign the removeListener event to our listeners such that it emits a removeListener event."

Tests are passing. That's all I can say.