added proper checks for localStorage (IE9 support) - close #520