fix cases in which smallest_matching_cidr() and all_matching_cidrs()
return incorrect results