The dangers posed by the justice and security bill are perfectly illustrated by the timely revelation that UK officials' potential complicity in the torture of a prisoner held in Afghanistan was disclosed in secret evidence in the Maya Evans case in 2010, yet this information was not revealed to her or the public.

The case is the only judicial review case to date to have used "closed" procedures of the kind that will become the norm in cases involving the military and security services if the bill is passed. It therefore stands as a test case for what we might expect should the bill become law.

Closed material procedures (CMPs) were, unusually, used in Maya's case with her legal team's consent because contesting the issue would have wasted valuable time. She also had no personal interest at stake in the litigation: she was challenging the UK policy of handing over prisoners to notorious torturers in Afghanistan on a public interest basis, as prisoners held in incommunicado detention were unable to bring the challenge themselves.

It is only because of the efforts of the legal team in a later case to "open up" some of the closed evidence from Maya's case that we have been granted a peek behind the curtain. It is not a pretty sight. What the newly revealed evidence shows is that highly material evidence that was embarrassing to the government was hidden from view, potentially jeopardising the fair administration of justice. How concerning then, that this should occur in the first instance of CMPs being used in judicial review proceedings.

In Maya Evans' case, two special advocates were instructed to act on her behalf in relation to the so-called closed material. As is the norm, neither she nor me or my colleagueson her legal team could communicate with them, or see any of the closed evidence revealed to them. We received one Ministry of Defence (MoD) closed statement in a heavily redacted form. It was relatively benign: it told us that government ministers had authorised the transfer of a prisoner to a detention facility in Kabul despite the MoD's own ban on such transfers. It reiterated the MoD's refusal to transfer prisoners where there was a torture risk.

However, the unredacted version of the statement that has now been obtained reveals critical information was omitted. It describes how the detainee in question complained of being tortured during interrogations. How he described being beaten repeatedly with a metal bar. How the foreign secretary and armed forces minister had personally authorised his handover. And how UK officials deferred to Afghan officials when they refused to grant access to this prisoner while the torture was going on, as they "recognise[d] the very real need to limit contact with others whilst building a relationship with a detainee.."

Here was evidence that UK officials facilitated torture of a UK-held prisoner at the hands of a foreign state – potentially criminal conduct – yet both the MoD and the court permitted this information to remain hidden. The issues revealed in this evidence are remarkably similar to the revelations that nearly brought down the Canadian government. Yet in the UK, our government and court system disposed of the issue without the public even knowing. Is this really what we want more of? None of the information could have damaged national security. Anonymity of the prisoner could have been preserved through other means, as it had been for other allegations. This was kept secret only to avoid embarrassment.

It is all the more galling that this information was withheld when in the "open" hearing, the MoD sought to contest the credibility of the known allegations of torture. Days were spent arguing about the MoD's suggestions that prisoners had fabricated their accounts, that they might make allegations for ulterior motives, that electrocutions would have left scarring etc. Yet, unbeknown to us, there in the closed material was an incontrovertible incident of Afghan torture, supported by photographic evidence.

And there in the closed material was the perfect illustration that even when the risk of torture was being evaluated on a single case basis by ministers themselves, with the benefit of advice and under the glare of litigation, they still couldn't assess the torture risk correctly. Here was good evidence that prisoners were being tortured as a result. Here was the perfect illustration of why the whole, broken, system needed to be stopped before anyone else was tortured. Yet we were told none of this.

The judgment was helpful, but did not go far enough, and it took a further two years of prisoners being tortured and a further case before the government decided to impose a moratorium on handovers in late 2012.

Much was made of the House of Lords "savaging" of the justice and security bill, yet closed material procedures remain. The final say over their invocation may now rest with the court, but many expect them to become the norm, and it will be difficult to appeal their imposition once in place. The Lords' failure to require that a balancing test be applied to evidence after a CMP has been invoked, to test what information can be passed into "open" is a worrying omission. Without it, CMPs will function like a black box into which information passes, but none emerges. That is precisely what has happened in the Maya Evans case.

And there is still more in this case that remains hidden. The court produced two judgments: an open one and a closed one. Under confidentiality undertakings, I was given just a small part of the closed judgment. But I cannot talk about the little I have, nor do I know what lies in the main body of that judgment. In light of what has now been revealed, this judgment must now also be opened up.

Even if further amendments are made to the bill, we are asking judges to be the sole guardians of the public interest in cases of this nature. We are placing our faith not in the judiciary as a whole, but in a single court. As Evans shows, this may be a weight that a single court cannot bear.

Judges get things wrong. That is why we have a system of appeals. But if claimants don't know there has been an error in the provision of information, the appeal system is illusory. The integrity of our legal system is at risk if we do not heed the warning of Evans and abandon this loathsome bill altogether.

Daniel Carey represented Maya Evans throughout her case