Pouchdb compatibility

A complete rewrite

* implement replication as documented in http://kxepal.iriscouch.com/docs/dev/replication/protocol.html
* every functionality into its own file
* unit tests
* adapter based on PouchDB api
* test against native replication api