Implement excepthook as a method rather than an attribute.

This allows overriding excepthook in a subclass of Loop, in addition to
the current method of assigning to the excepthook instance attribute.

Exceptions in excepthook are printed to stderr in addition to the
initial exception, to make debugging easier.

Added tests for the behavior of excepthook in the various cases.