Amniocentesis tests the fluid that surrounds the fetus. With the help of an ultrasound, a needle is inserted through the abdomen into the uterus to take a small sample of amniotic fluid. Amniocentesis tests for several genetic problems, gender, and the baby’s lung maturity. This test is usually performed between 16 and 20 weeks.