Bug fix for test db cannot be closed problem