Handle import exceptions correctly
Refactored the vm_import