Fix passing locals to extends

Pull Request #545 broke passing locals to `extends`. Specifically commit
2abc390e650ba6bce19a5575d291550e80815bc2. This adds a test that was
failing.
Merge pull request #552 from swalkinshaw/fix-extends-with-locals

Fix passing locals to extends