Fixes #139 by porting some of the changes from iOS

I did not attempt to port the refactoring related changes.

Also, I ran into issues porting one change in particular, see https://github.com/couchbase/couchbase-lite-android/issues/277

https://github.com/couchbase/couchbase-lite-android/issues/139
Merge pull request #176 from couchbase/feature/issue_139_startkey_docid

Fixes #139 by porting some of the changes from iOS