Enable non-string values to be formatted

Use Object.toString if the formatted argument is not a string.
Fix the tests.