Fix corner case in JSON escaped string parsing.

Add a few more unit tests. Redmine #5773