more progress on term unification, but still a bug in function unification