More robust localStorage detection