Fixed broken connection error, and quit test more gracefully