get hostnames with conditions + unit test