capture exceptions in tests