What is the best way to diagnose a bad mass air flow sensor? on 2005 Chevrolet Impala

I had the car running, hit it with a rubber mallet lightly, the car ran smoother, then I unplugged it and nothing changed. The car stalls and runs rough.

Asked by for the 2005 Chevrolet Impala
If the MAF was the problem, the car should run better with it unplugged, on a GM product. If you can bump it and the engine does better, it is a good sign that something is wrong with it or the connection to it.
Thanks. I replaced it and took care of the stall. Now it has a slight misfire, I diagnosed it to number 5 coil pack. I put a new coil pack on and now it runs horrible. Could it be a bad new part?
Check to make sure the wires are on correctly