Complete issue #226

Ensure that db is open before set last sequence in Replication
Merge pull request #239 from couchbaselabs/issue-226

Complete issue #226