SI-7221 Rewrites pollForWork tail-recursively

Fixes #1001407
Test stack behavior of pollForWork