paired_in and paired_out bug fixed, tests added