using $window for localStorage (testability)