Run tests on Travis and fix some compatibility issues

I'm testing against the fd argument which is either an integer/fd or a socket object, so this check should be fine.