Refactor to use storage backend

- Storage backend now a param to handler monad.
- Handlers are wrappers which extract backend from monad and invoke
  typeclass method.
- Most existing implementations moved to typeclass instance.
- Miscellaneous related refactorings to move a few bits (key types)
  between modules, etc.
Fix the (types) of CLI test