Fix type checking special case
Support nested functions
Fix nested overloaded function

This finally fixes #105.
Add test case
Improve error message reporting