This test measures how the lung surface works and how well the oxygen you breathe in goes through to the blood. It involves breathing in a specific mixture of gases. The gases used are all found in normal room air.
They include Methane and Carbon monoxide but in very, very small concentrations. Although carbon monoxide is a dangerous gas in large quantities, the amounts used for this test are very small and used in controlled conditions so you are safe. Carbon monoxide, is the same size and shape as oxygen and attaches to red blood cells faster than oxygen. So carbon monoxide can indirectly measuring how well oxygen goes through the lung surface.