Add test for restartAppIfNecessary