Use unify instead of union to properly unify inner terms of two references