Extract format module

Extract formatting utils used by unhandled rejection reporting, and add some unit tests.

See also #412 
Sure, I understand the inconsistencies of error reporting across browsers. Just to make it clear, let's be specific: the output contains the value of the `stack` property of the error object if it is present (whatever it contains across different engines), otherwise the error object is formatted as a plain object.