hoist determining of iteration count into a function, since it's needed in two places (easyblock.py and main.py)
fix typo