Sharpened latest snapshot.

Sharpened code from upstream commit 03895431fe71ed9ccd74c9cbc11ad88c8ae65602.
Tests were moved to couchbase-lite-android and were sharpened from
commit 3e7c99cb1ccf4693b023e893e22ddf946a32160d.