Fixes #146

https://github.com/couchbase/couchbase-lite-java-core/issues/146
Fixes #134

https://github.com/couchbase/couchbase-lite-java-core/issues/134