Add statuscode test and some love to on-error callback