Fixes #131 by porting iOS changes.  Unit test now passing.

https://github.com/couchbase/couchbase-lite-java-core/issues/131
Merge pull request #156 from couchbase/issue_131

Fixes #131 by porting iOS changes.  Unit test now passing.