Test for thread_id loops outside block_id loops

Fixes #335