Avoid valgrind to detect an error if test fails

If test fails connectio is not closed, valgrind detect a definitive leak
and mark it as an error. Moving variable to global make valgrind error
disappears.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>