fixing bugs in the mostSpecificType() method and the type unification mechanism