Superconducting Nb3Sn cavities with high quality factors and high critical flux densities