Implemented doc_ids support in replications

Fixes #102
Fixed memory/thread leakage of CBL_Servers

There was a reference cycle between CBLManager, CBLShared and CBLServer
that kept the CBLServer alive even after all CBLManagers were closed.
CBLServer owns a thread, which was also staying alive.
Also fixed a bunch of leaks in the unit tests where they weren't closing
a CBLManager they created.