Small fix (switching of two if clauses) to avoid issue with JSDom