Court upholds ruling in favor of Episcopal diocese