A book I edited once about older learners reported studies that showed better recall of material in an environment similar to the one in which you learned the material. It said that if you want the best chance of remembering your subject matter under test conditions in a classroom, you should try to acquire the learning under similar conditions.
I don’t doubt the studies, but if I had had to do all my studying under glaring lights at an uncomfortable little lecture-hall desk on a hard tile floor, I would never have studied at all.
I do study in the fullest quiet I can find, though, and I can imagine that studying to music would affect your recall when being tested in silence.