Fix #8570 and add test

This fixes #8570 and adds a simple test. `make testall` fails but that's because [the build is already broken](https://travis-ci.org/JuliaLang/julia/builds/36942408). The newly added test passes, and it should fail by hanging without the patch.
Look like you unintentionally introduced a tab here.