Links test cleanup

While debugging #8721 I noticed there was some opportunity for cleaning up and writing another test for this functionality.

* new test to ensure hosts files are being injected properly
* refactoring some common functionality into methods.

/cc @tiborvass @LK4D4 
Should be resolved now
> On Nov 4, 2014, at 3:14 PM, unclejack <notifications@github.com> wrote:
> 
> In integration-cli/docker_utils.go:
> 
> > @@ -715,3 +715,36 @@ func readFile(src string, t *testing.T) (content string) {
> >  	}
> >  	return string(data)
> >  }
> > +
> > +func containerStorageFile(containerId, basename string) string {
> > +	return filepath.Join("/var/lib/docker/containers", containerId, basename)
> > +}
> > +
> > +// docker commands that use this function must be run with the '-d' switch.
> > +func runCommandAndReadContainerFile(filename string, cmd *exec.Cmd) ([]byte, error) {
> > +	out, _, err := runCommandWithOutput(cmd)
> > +	if err != nil {
> > +		return nil, err
> ping @erikh <https://github.com/erikh>
> —
> Reply to this email directly or view it on GitHub <https://github.com/docker/docker/pull/8767/files#r19844347>.
>