Add a test for scoped storage and fix some problems.