Extract notification code into separate classes.

Improve test coverage.