Implement String#clear; close #2362

Fix memory leaks from #2362
Add tests of embed string and shared string.