The laboratory work presented here, simulates the chemistry on icy dust grains as typical for the "CO freeze-out stage" in dark molecular clouds. It differs from previous studies in that solid-state hydrogenation and vacuum UV-photoprocessing are applied simultaneously to co-depositing molecules. In parallel, the reactions at play are described for fully characterized laboratory conditions. The focus is on the formation of molecules containing both carbon and nitrogen atoms, starting with NO in CO-, H2CO-, and CH3OH-rich ices at 13 K. The experiments yield three important conclusions. 1. Without UV-processing hydroxylamine (NH2OH) is formed, as reported previously. 2. With UV-processing (energetic) NH2 is formed through photodissociation of NH2OH. This radical is key in the formation of species with an N-C bond. 3. The formation of three N-C bearing species, HNCO, OCN -and NH2CHO is observed. The experiments put a clear chemical link between these species; OCN -is found to be a direct derivative of HNCO and the latter is shown to have the same precursor as formamide (NH2CHO). Moreover, the addition of VUV competing channels decreases the amount of NO molecules converted into NH2OHby at least one order of magnitude. Consequently, this decrease in NH2OH formation yield directly influences the amount of NO molecules that can be converted into HNCO, OCN -and NH2CHO.