Fixed test that did not close db correctly