Feature/fix 500s

Because the if to check for generic 5xx errors was placed before the more fine grained one to check for specific 5xx errors, the special behaviour of return (deliver) for status 500 and 503 was not being picked up. This pull request fixes that issue.