Address remaining TODOs in DB code

Happy new year :)
This pull request fixes the TODOs that were left in the DB/Storage code. 99% of it was related to error handling, missing unit tests and just cleaning up the code. I also renamed TSEncryptedDatabaseError to TSStorageError. 
I tested the code and everything seemed to be working fine. I also haven't touched the core functionality of the DBs (getting/storing messages, keys, etc.) at all so this pull request doesn't actually change that many things.