Prepare test framework for python3 compatibility

Some general changes to test framework and shared test code

See merge request !1936
6 jobs for master
in 0 seconds, using 0 compute credits, and was queued for 0 seconds