refactor(storage): instantiate localStorage from a factory

Fixes #1921.

@ckarlof r?
@zaach got it from the JS Patterns book. Good enough for me!