Complete reference-counting for Function objects.

- Count references when storing Function objects in Yang structs.
- Delay deletion of Function object memory until execution has returned
  to C++, and they're definitely not referenced in Yang locals.
- Tests for this.
- Also some other tests which revealed a deficiency with
  mutually-recursive functions which will be fixed by closures.