unit testing error handling; better endless loop prevention