Add Jian's bugfix
Add test cases