Updated tests and db functions