fixes lock problems with dependent db destroying

basically the test created a race condition and attempted to destroy the db before it was fully closed, this also fixes the db not being deleted issue