Fix #7 and #8 - Detect function declaration as renamables AND make tests pass

I actually needed #7 to work, so I figured it was a good idea to also make #8 pass.
By doing so I refactored a bit and tried to improve readability.