The ProgramManager.waitForFinish() method calls the status endpoint to figure out if a program is running. Status endpoint checks if runtime info is available in the in-memory map. The runtime info for the program is added asynchronously through the listener mechanism, so it is possible that when a program is started, the status endpoint gets called before its runtime info is added to the in-memory map. Then, the ProgramManager.waitForFinish() returns immediately without running the program, causing test case failures.
Deprecate the waitForFinish() method and add a method waitForRun() to ProgramManager which will wait for the actual run records of the given status.