t4301: fix broken &&-chains and add missing loop termination