Factorize check_version function.