Refactor into smaller classes

Refactor the code into smaller classes for request duration and
exception notification.

Add the beginning to some tests.