Added test function for db query, rename some test functions