fixed NULL db and issue with testing