For Database: added tests and simplified interface