Adds unit test for Databases and a bugfix