Improving exception handling during tests