Fix problem with one sided internal loops

Internal loops with only nts on a single side would have the flanking pairs
reversed on the side without nts. This has been fixed as well as adding tests
for this case.