add test and revise swap bug

add test and revise swap bug