Reduce complexity factor of customError anc modify some tests that do not play well