Add unittest for db
Fix chainCloseDb