Court rules against banks in pivotal mortgage case