Improving exception handling in test and demos.