Ab-initio calculations for a realistic sensor: A study of CO sensors based on nitrogen-rich carbon nanotubes