Add pair test case and some source code clean up.