Modified testing script to handle failures