Implementation and test of hash and equals