Fix issue with global fallback when not in global namespace

This adds a test, and fixes an issue where a non-existant function is imported into a non-global namespace. Previously, this resulted in the global fallback being used. This patch addresses that issue.