tests: Fix test_shadow_reject which fails on some systems

The test was failing because 'nc -q -1' doesn't work as expected on some
systems, so it was replaced with 'nc -q 1000'. Some races in this tests
were also removed by replacing 'sleep 2' with more reliable ways to wait
a bit.

Change-Id: I4f2d688eb844d51a6243bf34c113ff0c83ed7df0