We explore a possibility that the 'Mozart effect' points to a fundamental cognitive function of music. Would such an effect of music be due to the hedonicity, a fundamental dimension of mental experience? The present paper explores a recent hypothesis that music helps to tolerate cognitive dissonances and thus enabled accumulation of knowledge and human cultural evolution. We studied whether the influence of music is related to its hedonicity and whether pleasant or unpleasant music would influence scholarly test performance and cognitive dissonance. Specific hypotheses evaluated in this study are that during a test students experience contradictory cognitions that cause cognitive dissonances. If some music helps to tolerate cognitive dissonances, then first, this music should increase the duration during which participants can tolerate stressful conditions while evaluating test choices. Second, this should result in improved performance. These hypotheses are tentatively confirmed in the reported experiments as the agreeable music was correlated with longer duration of tests under stressful conditions and better performance above that under indifferent or unpleasant music. It follows that music likely performs a fundamental cognitive function explaining the origin and evolution of musical ability that have been considered a mystery.