Cohen-Macaulay loci of modules