Fix resolving inside test files.

Also fixes #1036
Make sure all the other tests pass