It seems a new release of the W3C validator is not allowing h* elements to be inside legend elements (not clear if this was intentional as the changelog doesn't explicity mention it)
This is causing tests using the w3cjs library to fail while validating output from this library (e.g https://github.com/hmcts/look-and-feel/blob/master/templates/look-and-feel/components/fields.njk#L128)