tests: Fix race condition in FTP server setup

Don't sleep for 0.5 seconds but repeatedly ping the FTP server until it is
started up. Time out after 5 s.
tests: Fix two pyflakes errors