Fixed some bugs in testing