Fix missing attribute check in equal function

> Also reintroduced previously removed assertion