Your iMac should have shipped with the original Snow Leopard OS on two gray discs, Apple Hardware Test is on disc two of that original set. If you don't have your original discs you can try this tip;
How to run AHT w/o the system discs
1) SHUT DOWN the computer (Don't RESTART... shut it down)
2) Hold down the OPTION + D keys
3) Press the Power Button (make sure to hold down the OPTION + D keys first)
4) Continue to hold down the OPTION + D keys until the system enters AHT mode
5) Let the app verify the hardware setup before initiating the test.
6) There are two testing modes. To select the "Extended Test" activate the check box below the Test button.
7) Press Test button to begin test