refactor download command main

extract download_url function
add test