Fix tests across Python versions