How does an air bubble collect at the top of a test tube?

Gas produced during reaction will produce bubbles due to the property of surface tension of the liquid. Air or gas is less denser than the liquid in which it is produced. Also due to Archimedes principle, the weight of the liquid displaced by the air or gas bubble will be more than that of bubble itself. So upward buoyant force is heavy which pushes the bubbles to the top of the test tube.