Fix the headers splitting and value creation

This is almost the same code as the one from https://github.com/typesafehub/play-plugins/pull/59 I just found it too late. Please review them both and pick a common dominator or something

-- 
Nikola