Changed test and fixed some bugs