Add more testcase and modify source codes