On the production of cognitive achievement and gaps in test scores