On 24 June last year Cadbury's European president Matt Shattock went on BBC Radio 4's Today programme to defend his company's handling of the salmonella outbreak at its Marlbrook plant and the resulting product recall that would cost the company £30m.

"We identified a problem early. We corrected it and fixed it," he told bleary-eyed listeners.

With the benefit of hindsight this knee-jerk response looks to have been wildly optimistic. On 15 June, almost exactly a year to the day since news of the incident broke, Cadbury will appear in the dock. It is charged by Birmingham City Council on three counts of selling unsafe chocolate, failing food hygiene standards and failing to immediately report the contamination to the relevant authorities after the outbreak was traced to a leaky waste pipe at the plant.

Its latest statement on the matter has a more sober ring to it. "We have fully co-operated with the authorities throughout their enquires and we will examine the charges that have been brought," said a company spokesman last month. No wonder. If found guilty the company faces unlimited fines, or prison time for company executives.

So, now that it is about to take the stand, the question is: how did one of the UK's most trusted and iconic food brands get into this mess?

At face value this might appear like a simple case of negligence. But the incident highlights serious problems with how the current EU General Food Regulations are interpreted and the dangers inherent in sticking simply to the letter of the law when testing for contamination.

One flaw of the General Food Regulations, which govern food safety issues, is that companies can decide the appropriate sampling methods for products. So, prior to the outbreak Cadbury was doing just this in testing for salmonella. The lowest levels of salmonella thought to cause food poisoning in chocolate were 10 cells per 100g. Cadbury based its safety levels 100 times lower, at 0.1 cells per 100g. "We did this based on sound independent science," said a company spokesman at the time. "At all times we acted in good faith."

Another is that under article 19 of the law, companies are obliged to immediately inform the relevant authorities only if they have 'reason to believe' their products may be injurious to health. Cadbury insisted the levels of contamination were "significantly below the standard that would be a health problem". In short, it didn't inform the FSA because it didn't believe it had to. Cadbury said it found 0.03 cells of salmonella per 100g, far below its own strict safety levels of 0.1 cells per 100g.

The incident came to light after the Health Protection Agency discovered more than normal occurrences of salmonella poisoning reported between February and June and asked the industry to help shed light on the situation. It was at this point that Cadbury came forward.

The wording of the law throws up problems, says one legal expert. "There is a lot of subjectivity involved in deciding whether something is fit for consumption or not," he says. "The wording 'reason to believe' is very subjective."

It has to be a source of concern for the whole industry that Cadbury now finds itself in trouble even though it believed it was working well within safety thresholds.

Richard Matthews, head of product liability at law firm Eversheds, spells out some of the dangers. "The difficulty food manufacturers face is that by just complying with a legislative threshold it doesn't follow that they are immune from a recall," he says. "It is difficult for food manufacturers and ingredient suppliers to keep up with best practice. Limits of detection change as technology develops, enabling potential contaminants to be found at smaller levels. This can create problems in the event of a recall."

To avoid the threat of a recall, food companies must ensure there is no question whatsoever about the safety of a product. "If you give consumers a choice between a product with any levels of a dangerous substance and one without, you know what they will choose," he points out.

In light of new guidelines set by the FSA, Cadbury has subsequently set a zero tolerance level for salmonella. And, while some companies still test products only after they have left the factory, Cadbury has joined others in moving to a 'positive release system', where products are tested before they leave the factory, so that unsafe doesn't reach the shelves.

Cadbury has also increased its sampling and testing programme. "Only releasing products when the results are clear helps reassure customers that they can trust our product," said Cadbury Schweppes head of external communications Tony Bilsborough earlier this year.

The incident also throws the spotlight on the effectiveness of traceability across the food industry, however. Traceability legislation, which came into force in January 2005, requires manufacturers to provide the names of businesses who supply them and to whom they supply products - known as the one-up, one-down principle. However, it does not require any internal traceability, meaning companies are not required to identify how batches are split and combined to make products.

Jeremy Moore, head of product risk at risk advisor Marsh, says companies need to have much better traceability systems in place than the law currently requires if they want to avoid causing serious lasting damage to their brands. Salmonella is believed to have entered Cadbury's Marlbrook plant undetected in silos of its chocolate crumb, which is used as an ingredient in around 30 of its brands. Using the company's traceability records the contamination could be narrowed down to just seven possibly infected brands.

"From a traceability point of view, it's all very well a company complying with the one-up, one-down regulation, but from a corporate perspective the exposure of an unsafe product should encourage companies to go well beyond this," says Moore. "One-up, one-down should be a bare minimum."

The government is making moves to encourage manufacturers to take a closer look at their traceability systems. In March an FSA task force published a 74-page guidance document for preventing and responding to food incidents and has set up a panel to look at what lessons have been learnt from two other recent high-profile food scares - Sudan 1 and Para Red.

"There has been good cooperation in agreeing these guidelines, and the members of the task force may continue to meet and work on some strategic targets," says Dr Lynne Ridler-Wall, head of the FSA's emergency planning, radiation and incidents scheme.

Companies do seem to be taking note as the threat of court action and increasingly expensive recalls become a reality. The £30m figure Cadbury claimed the salmonella outbreak has cost it, plus the unlimited damages it now faces, will have no doubt been factors in the rising number of food and drink companies taking out product recall insurance, according to Mark Kendall, partner at Reynolds Porter Chamberlain.

"There is a marked increase in the number of insurance products that pay for the cost of a recall and cover a dip in profits," he says. "I expect in boardrooms across the country they are discussing whether to buy insurance cover. It is an area we will see further growth in."

Indeed, the major multiples are starting to demand it of their suppliers so they can prove suppliers have the funds for a recall and can continue trading. The press coverage the Cadbury incident received has highlighted the importance of moving quickly when responding to a food scare, he adds.

"The legal costs and compensation can be colossal, so the need to recall quickly is vital, and so is insurance cover. The press and courts will punish them if they are seen to be dragging their feet."

There are encouraging sounds coming from the industry.

"Companies contacted me after the Cadbury incident to ask what they could learn from it," says Tony Hines, director of crisis management at food research association Leatherhead Food International. But he warns: "It's an ongoing challenge and it won't get any easier because the food chain is so diverse, so the potential for anything to go wrong is enormous. The industry has raised its game and become more professional to manage those situations."

The globalisation of the supply chain adds further to thge risk, says Marsh's Moore: "The sourcing spectrum of an average company is so much more varied than in previous years and this would suggest companies are open to more risks."

Moore cites a recent study among global food and drink companies that revealed poor levels of traceability in some of the biggest manufacturers. "Companies need to identify where all affected products have come from and be able to do something about it very quickly, but many can't," he claims. "I still see the possibility of another large food scare. I'm not convinced that every food and drink company could say they know exactly where their ingredients come from, which is a problem."

The outcome of next month's court case will no doubt shed further light on what went wrong at Cadbury. The supplier is expected to plead not guilty to the charges.

Whatever the outcome, it will have a profound impact on how the industry views its safety procedures in the future. Food safety may not be a pipe dream but, as Cadbury has already found to its cost, it's better to have a pipe that doesn't leak.nthe cadbury case

Cadbury will go to court on 15 June charged by Birmingham City Council on three counts - for selling unsafe chocolate products, for failing to immediately report salmonella contamination to the regulating authorities and for failing to meet standard food hygiene and hazard controls.

The first two alleged offences involve breaches of the General Food Regulations 2004, the third is an alleged breach of Food Hygiene (England) Regulations 2006.

If found guilty, the company could face unlimited charges and the executives involved a two-year prison sentence.

Cadbury's defence is likely to hinge on the fact that it did not inform officials that its products could be contaminated with salmonella because only minute traces of the bacteria were found and it deemed the risk to consumers' health too low.

Article 4 of the General Food Regulations states that food companies shall perform testing as appropriate and that they should make decisions in the context of their safety procedures based on HACCP principles and good hygiene practice.

A spokesman for Cadbury said earlier this year: "Under the legislation, it is left to the manufacturer to determine the testing protocol. We did this based on sound independent science. At all times we acted in good faith."