Ex-Pakistan PM Khan appears in court after arrest fiasco