The TSI test is used to determine carbohydrate fermentation and hydrogen sulfide production in bacteria. It contains glucose, sucrose, and lactose sugars, along with peptones and phenol red pH indicator. Carbohydrate fermentation produces acid, changing the color from red to yellow, while peptone metabolism makes it more alkaline. Hydrogen sulfide production is shown by black precipitate. Results are interpreted based on color changes in the slant and butt portions, indicating which sugars are fermented and if H2S is produced.