fix bug with bad mid point, add testcase
change test case