A Zimbabwean court has freed an opposition leader and 34 activists who had been in detention for more than five months.