Fix for session handling

closes #1978
- wait for async calls before callback()
Merge pull request #1979 from sebgie/fix-session-1

Fix for session handling