Replication finished observer called before processing all changes

The replication finished observer in the majority of the times is called before processing all requests. This is probably provoked by race conditions updating replication's completedChangesCount. This error is intermittent but it happens more than 50% of the times. 

I also notice that when increasing the number of documents in the changes feed to 100, you can see symptoms of issue https://github.com/couchbase/couchbase-lite-java-core/issues/100 . And in this case the error is not only sporadic, as it happens 100% of the times.