Quantum nondemolition measurements on two-level atomic systems and temporal Bell inequalities