Refactor old version of toString.
Refactor.

Add unittest for wide-string formatting.