Python 3 compat: Improve subprocess and tests