Fix #736 Python Error when assigning data type using Key Editor. Also ensure qgis is imported for all tools tests