Fixes in database tests - workaround for database closing problems