Refactored the factory into a form of provider to make localStorage key configurable