Testsuite: Fix racy conditions in py-cmd.exp