Update equality check function and fix some tests