handle exceptions in test