fixes some bugs in unit tests