fwiw, thc is stored in fat cells, which is commonly accepted as fact. The exact course of action that is best to take is a matter of debate, but imo, at least don't be burning fat the few days before the test. Putting on fat while you are clean is probably not a bad idea, either. There are a million and one home recipes for the best concoction to be drinking: golden seal, green tea, and cranberry derivitives are at least probably not unhealthy for you. Modern urinalysis will reject a sample that is too watered-down. Some 'pass your test' drinks that used to work for some people might not work for you.
The best advice, and you would be surprised at how many people don't do this, is to stop smoking pot, at least until your test results come back clean. Don't go get bombed immediately after your test, or else you risk the lab losing your sample or having to re-test for some mundane reason. It happens a lot. Also, don't be around your friends when they are smoking; any little bit that you inhale secondhand is not helping your cause.
If you still fail, then you are at the mercy of the system, but fwiw everyone you meet - po, da, public defender, judge, they all have the discretion to divert you away from jail. Treat everyone with the utmost respect, and do the best to negotiate your case with everyone. Offer to do community service or drug rehab; anything is better than jail. Play the part of the likeable good kid who made a few mistakes, but does not deserve incarceration. It's easy to get mad and have an 'FU' attitude with everyone you meet, but that only makes them throw the book at you. Be smart and work the system. Good luck.