Tests

All these fixes combined make the Travis build succeed.

It also makes 'go test' run on my machine (as long as I remember to generate the test data...) (Debian testing, Elasticsearch 1.4.1)