Extract format module

Extract formatting utils used by unhandled rejection reporting, and add some unit tests.

See also #412 
I guess I should change it to just say "should *be* the stack trace".  Unfortunately, formatting and outputting errors across the inconsistencies of various JS engines is tricky.  So, we've found that usually the best option is just to directly use the `stack` property if it's there.  For example, in v8, the `stack` property includes both the error message, and the the stack trace.