Share code for creating database for testing

Signed-off-by: Michal Čihař <michal@cihar.com>
Use random database name for each test

This way multiple tests can run at same time without causing problems.

Signed-off-by: Michal Čihař <michal@cihar.com>