Ensure IndexedDb is closed and more tests

- Made sure IndexedDb is properly closed
- Removed duplicate error handler
- More tests for IndexedDb