Trump’s attacks on judges and courts test strength of measures to check power of the president