tests and improvements in link.c