Making sure IndexedDb is closed

- Moved closing call to occur outside callback function check
- Added closing call where missing
Removing duplicate error handler
Updating and adding more tests (IndexedDb)

- Made sure that IndexedDb is closed when not needed
- More tests