Extract store initialization to a shared function

The store is initialized in two places, main and do_reset. Move the
initialization code to a separate function which can be called from both
places.

Signed-off-by: Marcus Karlsson <mk@acc.umu.se>