Fix "resource" for reference fields.
Add tests.
More tests.
More fixes
Merge remote-tracking branch 'origin/233' into fk-restful