Fixing broken while loop in imports.py

This commit is backporting commit 64ef5bf5. It could not be
cherry-picked, as the unit test code had lot more dependent code to be
pulled in.

Issue: flake8 occasionally encounters "H302  import only modules."
error even though the python module exists at the path and python
shell is able to import the same.

Root-cause: The while loop in is_module_for_sure() had a bug, where
iterating variable, 'mod_name', was getting derived from the same
input, 'mod', every time. It should have led to an infinite loop
otherwise. But, an ImportError takes it out of the loop. Most of
the cases, this is not an issue, if as part of the exception handler,
built-in __import__() finds the module. The evidence of the issue is
the availability of import statements suffixed with "# noqa" to
work-around the bug.

Fixing the while loop causes the logic to flow in the original path of
the code to use 'imp.find_module()'

Change-Id: I421a66242121b987b7c8c1568394478514073b87