Fix multifile async scope issue

Fixes by moving offending code into a separate function and calling it
inside the for loop thereby scoping things correctly.
Refer to #18 for issue ticket.
Merge branch 'fixMultifileScopeIssue'