Refactor test for hosts returned
Refactor SQL query down a little and switch to INNER join