Extract format module

Extract formatting utils used by unhandled rejection reporting, and add some unit tests.

See also #412 
The method formats **only** the `stack` if it is present. **"Including"** a stack trace confused me because from such docs and the test spec I expected to see something more in addition to the stack (e.g. `name`, `type`, `message`, `code`, maybe timestamp when the error occurred).