seperated out database stuff from main check_twiddle library to make it more modular, also added more tests due to the refactor