test and fix some bugs