Change test to avoid race condition

The old way of testing this had a race condition if the gearman srever
didn't reply at the right time. Now it's a true unit test so we can
avoid these issues.