refactor(storage): instantiate localStorage from a factory

Fixes #1921.

@ckarlof r?
I wanted to avoid peeking at private properties. Maybe there's another way.