Fixes #2689 - Makes pass tests about filtered replication

I think i've changed may be the "core" of the replication algoritm to fix this.

Tests are green, so... 

@nolanlawson @calvinmetcalf  ?