[TASK] Ensure configured element count

Fixes #628.
Last revision before merging:

Please assign intermedia variable for `count($output)` since this expression is used twice.