Don't attempt to call db.setLastSequence if db closed

Added in reaction to seeing errors in logs: java.lang.IllegalStateException: attempt to re-open an already-closed object: SQLiteDatabase: /data/data/com.couchbase.lite.test/files/test/cblite-test.cblite
Don't call pendingSequences.first() if empty

Added in reaction to java.util.NoSuchElementException
Fixes #295 by checking if the db is null before calling forgetReplication.

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