fix residue-based selection when there are multiple levels of fragments
clean up test