pyterm: integrated changes from @mehlis' testbed-controller branch