You should have the dog tested for heartworms first because once you start treating, the test won't work anymore.
Modern day Heartworm tests are designed to detect the presence of antigens in the bloodstream from female adult heartworms, not the detection of microfilaria. Depending on the test method, whether or not the dog is currently being treated with a preventative should not affect test results.
You spent some time with a calculator!