Fix create_vm code path

 - Remove sleep (Check for running tasks instead)
 - Code refactoring to move delete_vm/vapp/template into separate function