Fix test compatibility for python3+