Fixed bug in TestMain