Add StringParserTest and some toString methods

Fixed bugs in StringParser and added test cases.