Add error handling when running tests