Add util functions for integer parsing (with tests), and factorize integer argument parsing to avoid code duplication.