Correct use of inheritance in egal test

The egal test checked that inheritance resulted in the same object by
inheriting from a variable, which is invalid. Instead, it now captures a
reference to self during construction and inherits from a method.