Prevent possible deadlocks in tests

Signed-off-by: Moritz Ulrich <ulrich.moritz@googlemail.com>