trq-2499 Cleaned up the list traversing code.
Added a case to unit tests to account for passing in a host with a user.