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
Merge pull request #5 from joseeight/tests

Ensure IndexedDb is closed and more tests