Fix tests on python 2, muon code improvements