add some database routines + tests