Refactor: shrink hosts class method and add tests