Court upholds church exception to laws against firing