add test codes and modify some bugs