Factor out testing error checks
Factor out testing status checks
Factor out error type checks
Formatting in error message