improved db efficiency, restructured tests, added unregister functions