added test for apc and small fix to get_pairs