Improve DatabaseManager tests.

Test for recovery missed the case when failure occurs just before the
temporary file is deleted. No bugs found but test is good to have.
Fix bug where available copies were too eager.

We need to wait for successful commit() in order to make available a
copy for reading. Previously this was done when try_write() succeeds.
However, if the transaction fails then the copy is marked for reading
erroneously.