Modified  waitForActivity() to solve an issue that happens on some devices, issue-416