Correctly log errors in `setup` and `teardown` functions

Fixes #30