func htmlLinksHandler(w http.ResponseWriter, r *http.Request) {
	start := time.Now()
	status := 200
	if strings.Contains(r.URL.Path, "/404/") {
		status = 404
	} else if strings.Contains(r.URL.Path, "/302/") {
		status = 302
	}
	linksHandlerCalls <- r.Host + r.URL.String()
	if sleep := 10*time.Millisecond - time.Since(start); sleep > 0 {
		time.Sleep(sleep)
	} else {
		fmt.Println("Something is slooow here.", sleep)
	}
	http.Error(w, "Link Handler", status)
}
this handler needs at least 5 ms for each response.
package ht
import (
	"fmt"
	"net/http"
	"net/http/httptest"
	"net/url"
	"strings"
	"testing"
	"time"
)
var sampleHTML = `<!doctype html>
<html>
<link href="/css/base.css">
<head><title>CSS Selectors</title></head>
<body>
<h1 id="mt">FooBar</h1>
<p class="X">Hello <span class="X">World</span><p>
<p class="X" id="end">Thanks!</p>
<a href="#">Link1</a>
<a href="/foo/bar">Link2</a>
<a href="../waz#top">Link3</a>
<a href="http://www.google.com">Link4</a>
<img src="pic.jpg"><img src="http://www.google.com/logo.png">
<script src="/js/common.js"></script>
<script>blob="aaa"</script>
<div class="WS">
  <p class="em">Inter<em>word</em>emphasis</p>
  <p class="strong">
	Some
	<strong> important </strong>
	things.
  </p>
  <ul class="items"><li>Foo</li><li>Bar</li><li>Waz</li></ul>
  <ul class="fancy"><li>One</li><li>S<strong>econ</strong>d</li>
     <li> Three </li></ul>
</div>
<p>Large 24&#034; Monitor</p>
<p>Small 12" Monitor</p>
</body>
</html>
`
var hcr = Response{
	BodyStr: sampleHTML}
var htmlTagTests = []TC{
	{hcr, &HTMLTag{Selector: "h1"}, nil},
	{hcr, &HTMLTag{Selector: "p.X", Count: 2}, nil},
	{hcr, &HTMLTag{Selector: "#mt", Count: 1}, nil},
	{hcr, &HTMLTag{Selector: "h2"}, errCheck},
	{hcr, &HTMLTag{Selector: "h1", Count: 2}, errCheck},
	{hcr, &HTMLTag{Selector: "h1", Count: -1}, errCheck},
	{hcr, &HTMLTag{Selector: "p.z"}, errCheck},
	{hcr, &HTMLTag{Selector: "#nil"}, errCheck},
}
func TestHTMLTag(t *testing.T) {
	for i, tc := range htmlTagTests {
		runTest(t, i, tc)
	}
}
var htmlContainsTests = []TC{
	{hcr, &HTMLContains{Selector: "p.X",
		Text: []string{"Hello World", "Thanks!"}}, nil},
	{hcr, &HTMLContains{Selector: "#mt",
		Text: []string{"FooBar"}, Complete: true}, nil},
	{hcr, &HTMLContains{Selector: "span",
		Text: []string{"World"}}, nil},
	{hcr, &HTMLContains{Selector: "span",
		Text: []string{"World"}, Complete: true}, nil},
	{hcr, &HTMLContains{Selector: "p.X",
		Text: []string{"Hello World", "FooBar"}}, errCheck},
	{hcr, &HTMLContains{Selector: "p.X",
		Text: []string{"Hello World"}, Complete: true}, errCheck},
	{hcr, &HTMLContains{Selector: "p.X",
		Text: []string{"Hello World", "Thanks!", "ZZZ"}}, errCheck},
	{hcr, &HTMLContains{Selector: "div.WS p.em",
		Text: []string{"Interwordemphasis"}}, nil},
	{hcr, &HTMLContains{Selector: "div.WS p.strong",
		Text: []string{"Some important things."}}, nil},
	{hcr, &HTMLContains{Selector: "ul.items",
		Text: []string{"Foo Bar Waz"}}, nil},
	{hcr, &HTMLContains{Selector: "ul.fancy",
		Text: []string{"One Second Three"}}, nil},
	{hcr, &HTMLContains{Selector: "li",
		Text: []string{"Foo", "Bar", "Waz"}}, nil},
	{hcr, &HTMLContains{Selector: "li",
		Text: []string{"Waz", "Bar", "Foo"}}, nil},
	{hcr, &HTMLContains{Selector: "li", InOrder: true,
		Text: []string{"Waz", "Bar", "Foo"}}, errCheck},
	{hcr, &HTMLContains{Selector: "li", Complete: true,
		Text: []string{"One", "Waz", "Bar", "Foo", "Three", "Second"}}, nil},
	{hcr, &HTMLContains{Selector: "li", Complete: true, InOrder: true,
		Text: []string{"One", "Waz", "Bar", "Foo", "Three", "Second"}}, errCheck},
	{hcr, &HTMLContains{Selector: "li", Complete: true, InOrder: true,
		Text: []string{"Foo", "Bar", "Waz", "One", "Second", "Three"}}, nil},
	{hcr, &HTMLContains{Selector: "p",
		Text: []string{`Large 24" Monitor`}}, nil},
	{hcr, &HTMLContains{Selector: "p",
		Text: []string{`Small 12" Monitor`}}, nil},
	// Nice error messages
	{hcr, &HTMLContains{Selector: "p.X span.X",
		Text: []string{"Foo"}}, fmt.Errorf(`Missing "Foo", have ["World"]`)},
	{hcr, &HTMLContains{Selector: "p.Y span.Y",
		Text: []string{"Foo"}}, errTagNotFound},
	{hcr, &HTMLContains{Selector: "li", InOrder: true,
		Text: []string{"Foo", "Bar", "Waz", "One", "missing", "Second"}},
		fmt.Errorf(`Missing "missing", have ["Second" "Three"]`)},
	{hcr, &HTMLContains{Selector: "p.X",
		Text: []string{"missing"}},
		fmt.Errorf(`Missing "missing", have ["Hello World" "Thanks!"]`)},
}
func TestHTMLContains(t *testing.T) {
	for i, tc := range htmlContainsTests {
		runTest(t, i, tc)
	}
}
func TestW3CValidatorHTML(t *testing.T) {
	if testing.Short() {
		t.Skip("Skipping W3C Validator based checks in short mode.")
	}
	body := `<!DOCTYPE html>
<html>
<head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
  <title>This is okay</title>
</head>
<body>
  <h1>Here all good &amp; nice</h1>
</body>`
	rr := Response{BodyStr: body}
	check := W3CValidHTML{
		AllowedErrors: 0,
	}
	runTest(t, 0, TC{rr, check, nil})
	body2 := `<!DOCTYPE html>
<html>
<head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
  <title>This is okay</title>
</head>
<body>
  <h1 title="K&K">Here some issues problems</h1>
  <button role="presentation">Button</button>
  <span><div>Strangly nested</div></span>
</body>`
	rr2 := Response{BodyStr: body2}
	check2 := W3CValidHTML{
		AllowedErrors: 1,
		IgnoredErrors: []Condition{
			{Prefix: "& did not start a character reference"},
		},
	}
	runTest(t, 1, TC{rr2, check2, errCheck})
	check3 := W3CValidHTML{
		AllowedErrors: 3,
	}
	runTest(t, 1, TC{rr2, check3, nil})
}