Made database code more central
Made tests clean up image files