Fixes some bugs in testcode