Use Text representation of database instead of Database type
Add even more tests and fix bugs