found and fixed some bugs while unit testing