fixed testing cmp so the invariant tested matches it