Fix invalid bounding rect dection in screenshot tests.