Fix tests and clean up undecorate_resource