pktools/lib/utils.py: improved logic of factory method
pktools/lib/utils.py: improved logic of factory method

Made minor improvements to logic of factory method in utils.

Signed-off-by: MegaMetapod <48ee6722255b619da9249aa56ff43c3552d60ba3@users.noreply.github.com>

MegaMetapod/pypktools