fix check_resource, add tests