Fixed some bugs in the test functions