fix bugs
add test cases at exception. And fix bugs.