I think what happen to you is very common in training, especially at night under Nods. If a malfunction is going to happen, it will always be in the middle of a training class it seems. It sounds like you did just fine. When you stress test your skills you might do something slightly different than what you've ever done before. No big deal as long as you stick to good safety and still can function. That sounds what you did so I don't see any big deal here.
I think lots of folks forget where their safety is when under stress. The fact that you are checking or re-checking to insure it's where it needs to be is the key point here, not that you got temporarily dis-combobulated. I have forgotten to put safety on or off under stress, but I was also following the other rules, especially by keeping good muzzle control and finger off trigger. So yes that was bad, but I didn't have a NG because I was following the other safety rules, and I learned from it. I am not implying that is what you did here; just illustrating a point.
I disagree with the concept of always staying behind cover if you have a malfunction. If your team is advancing, and you stay behind to fix your weapon, you have two issues, First is the safety issue of everyone not being roughly on line together. Especially at night. For training I would stress the idea of staying with your team more than fixing your weapon. Keep moving with them and fix it when you can. Tell your buddy you have a malfunction so he can take up the slack (hopefully) in shooting while you get it fixed. Second is the idea of working with a team. If you have let's say at least 4 guys assaulting a position, remember there's 3 other rifles out there. If you're not shooting it doesn't mean the enemy isn't getting effective fire. You could still advance with them, with a non-functioning gun, to stay together with them, and fix it (behind the next position of cover) while your buddy ups his rate of fire to compensate.
I know a lot of guys are used to working alone, and the idea of doing something like thus sounds crazy. But for safety reasons, and with trust in good team mates, it can be done. It's what I have done. It's" A" way of doing things, for your consideration.
When doing a live fire night assault, under Nods, I have seen many similar issues. The first time you change mags at night, live fire, under Nods, is an experience. Clearing a malfunction must be doubly so. What I have found to really help, is to run a Wilcox filter, so I can run the Nod at a slight stand-off, which does two things, First I can now wear safety glasses. Secondly, the slight gap gives you a huge amount of situational awareness, because you can now see around the gap of the eyepiece. For the price of some field of view, you can now see close up on your Nod side. The filter cancels out the "raccoon eye" you would normally get by doing this.
Also, I think having a small IR light (or at least ranger eyes) on everybody's head makes a lot of sense, in training as well as in actual assault. I know some guys will disagree with that, but I think having some kind of IR visual light to mark where everyone is, makes a lot of sense. Not to mention Lum/ IR patches on your shoulders, which really help to keep everyone on line.