improved error testing for deploy
improved download_code and implemented copy_code for deploy