fix(library/unifier): broken optimization in the unifier

See new comments and tests for details.