refactor(storage): instantiate localStorage from a factory

Fixes #1921.

@ckarlof r?
This naming is a little strange in relation to how factory methods are typically named, but it's probably fine for now.