Extract format module

Extract formatting utils used by unhandled rejection reporting, and add some unit tests.

See also #412 
This `equals` confused me, the "inclusion" is usually checked with an `indexOf` or the like.