Unfortunately, we are still somewhat technology limited. It'd be nice if we could routinely peek into the blood smear and actually see the HIV, but it doesn't work that way.
Most of the screening tests are so-called ELISA (
Enzyme-
Linked
Immuno
sorbent
Assay). It's a test where-in the test substance (little wells for blood, some commercial things sort of resembling a pregnancy test) are coated with proteins from HIV (these are called antigens). You then put the subject's blood (serum, plasma) onto the test substance.
If the subject has HIV, then as part of the immune response, the body makes antibodies to many of the HIV proteins (including the antigens coating the well). So in an infected individual, the test substance is now coated with the test subject's antibodies to HIV.
As part two of the test, the test substance is washed with a solution of lab created antibodies. These antibodies are created to do two things: attach to ANY human antibody on the test substance (ie, our proposed test subject HIV specific antibodies now stuck to the test substance) and carry a special enzyme marker. The enzyme marker serves an indicator purpose (typically it makes a color spot, blue or black or whatever it is designed for) and will light up the test substance and basically say "POSITIVE" when present.
The ELISA test is the standard screening test. It is powerful, cheap, and right about 99.9% of the time. But it isn't perfect and can be confounded in a couple of ways.
The first is simply a function of the immune response. If you have an infection, you attack it in a host of ways. You send in spy cells that break down the infection particles (bacteria and viruses both) and then send those to other cells that use them to make antibodies. In many infections, this production of antibodies is quite helpful in helping to control or eradicate the infection (we use this property for Measles, Mumps, Rubella, Polio, Smallpox, Diptheria, Tetanus, etc). It takes time to build this response however, and typically 3 weeks is the absolute minimum (that is seen in very aggressive bugs, like Measles and the like). HIV is indolent (slower in progression) and so is the immune reponse, so up to 6 months is considered a reasonable window for seroconversion (appearance of sufficient antibodies to be detectable).
So if you get tested in the window before you have mounted a sufficient antibody response, the test will be falsely negative.
The second way it is possible to confound the test is the presence of what is called cross-reactivity. The human machine is a dynamo, and one we don't understand 100%. Occasionally, you will make an antibody that for some reason closely enough resembles one of those HIV specific antibodies that it will bind there. The ELISA then shows up positive (and it is really negative). That is why, in cases of ELISA, in the USA at least, laboratories are required to do the confirmatory test to PROVE that the patient has floating HIV RNA running around. That test takes longer and is more expensive, but was found necessary in the late 80's/early 90's after the first several rounds of suicides over false positive tests.
The other tests for positivity (HIV viral load) (HIV RNA) are longer, more expensive and are used typically to confirm that ELISA is right, or to monitor response to therapy (ie a viral load that is undetectable is optimal).
And before you wonder: I am in the field, and my undergrad major focused heavily in cellular biology (nerd!). The HIV model is an ongoing project that was often used to discuss host-immune response.
My God that was long-winded.

if anyone made it this far.