Fix IO_Write for strings which are not in IsStringRep

Also add a test case for the issue.

Fixes #19, closes #20, closes #21, fixes #22, resolves #23