Avoid a warnings about undef used as a hash key

If the data structure contains an undef, it would generate a warning when
recording the seen items.  Besides avoiding putting undef in the hash,
we'll generalize and skip the loop unless it's a reference - regular
scalar values don't need to be further processed

Change-Id: Id99759a14d406c08d7efc3274b8fe391be7a86c5
Forgot to bump up the number of tests

Change-Id: I7a2fa7f10879b3ecc4b464dd0a35d8decb8eed60