Create databases on initialization to improve concurrency issues.
Make writing to the database concurrency-friendly.
Performance tweak for tests.
Merge branch 'safe-write' into fork-master