1 answer
(click or scroll down)
A 8g of hydrogen gas escaped from the test tube.
The chemical reaction between hydrochloric acid and magnesium produces hydrogen gas, which can easily escape from the test tube. This accounts for the missing 8g of mass.