Fixes #292.

ReplaceDatabase would previously result in a
database file corrupt error after calling
it on an existing database.

This was largely because it replaced the file
without reopening the database. Instead,
we don't first open the database, replace
the files, and *then* open it.
Merge pull request #293 from couchbaselabs/issue-292

Fixes #292.