finished test and fixed some bugs