Re-write test code for Pairwise algorithm

Re-write test code for Pairwise algorithm