Fixed some db and log issues, tests working