improved inspect links algo, added patch testcase