Refactor DNS caching into struct

Refactor the two DNS caching functions in `main_test.go` into private and
public methods on a single struct. This stops them using the `*edgeHost` and
`hardCachedEdgeHostIp` global variables and makes them easier to reason
about. Because of this we can also move it to the helpers file. Function
documentation has been updated to reflect how it's now split up.