Fixed json serialization to TextWriter. Tests added.

Json deserialization with TextReader of data that has been serialized with TextWriter was broken.