Fixed unbounded memory allocation in local storage
fix undefined var, add test
Merge branch 'issue80'