refactor(storage): instantiate localStorage from a factory

Fixes #1921.