Are there any examples of mathematicians have produced good research, having done poorly in mathematics exams?
Well Ramanujan was such a mathematician. He was not so poor in math exams but he scored somewhat unbelievable marks in mathematics. In $1907$, he appeared in FA Examination at Pachaiyappa College, after studying privately. He got $85$ out of $150$ in mathematics and failed in English, Sanskrit, Physiology and History. Now one would expect that Ramanujan would get $100\%$ by analyzing his ability to tackle hard problems, but it was not so. But as we all know, he was very good at research. The reason for his scoring low marks in examinations are discussed here by Berndt.
The most famous case of this sort is Galois failing the entrance exam to Ecole Polytechnique.
Newton somewhat infamously failed his examinations at Cambridge: he was questioned orally about the proofs in Euclid, and since he had looked at Euclid once and thought it a total waste of time, and had just rederived all the results himself, he had no idea how to answer things like "How does Euclid prove X.1?"
Somehow he was awarded the scholarship anyway - presumably someone noticed that they were dealing with Isaac Newton.
G.H. Hardy. From http://www-history.mcs.st-and.ac.uk/Biographies/Hardy.html
"While at Winchester Hardy won an open scholarship to Trinity College, Cambridge, which he entered in 1896. At Cambridge Hardy was assigned to the most famous coach R R Webb. He quickly realised that the point of the training was simply to achieve the best possible marks in the examinations by learning all the tricks of the trade. He was shocked to discover that Webb was not interested in the subject of mathematics, only in the tricks of examinations.
Hardy was placed as fourth wrangler in the Mathematical Tripos of 1898, a result which continued to annoy him for, despite feeling that the system was very silly, he still felt that he should have come out on top."
Wikipedia adds "Years later, he sought to abolish the Tripos system, as he felt that it was becoming more an end in itself than a means to an end."