Adds the final line of output to tests and properly simulates failure. Fix with type casting to prevent calling methods on nil and drop the final entry as it's not valid. Fixes #9806
Adds the final line of output to tests and properly simulates failure. Fix with type casting to prevent calling methods on nil and drop the final entry as it's not valid. Fixes #9806