fix major bug that caused test failures

https://github.com/couchbase/couchbase-lite-android/issues/398
fix NPE

https://github.com/couchbase/couchbase-lite-android/issues/398
fix issues with distinguishing transient errors that caused test failures.

https://github.com/couchbase/couchbase-lite-android/issues/398