Added exception handling to test files