test-server: extract code that parses collected headers