Extract format module

Extract formatting utils used by unhandled rejection reporting, and add some unit tests.

See also #412 
Yeah, it seems like it'll just work since we're browserifying the tests.  Not sure when I'll have a chance to test it, but hopefully within the next week or so.