Fix Issue 11945 - LockingTextWriter.put

The function just had sloppy constraints while assuming it was a string. This fixes it up and adds some basic unit tests.

https://d.puremagic.com/issues/show_bug.cgi?id=11945
Merge pull request #1887 from Poita/bug11945

Fix Issue 11945 - LockingTextWriter.put