Add unit tests for the hooks

Tests whether the hooks run (trivial) and whether they run correctly
and raise appropriate errors.

Change-Id: Ib5c9ff41fbd145c0ae3de6b3729c6a673345e98a