Use waitForActivity instead of getLastActivity as suggested by issue-586
Bugfix for issue-585