[#51] Turn headers into a dict before JSON seraliazing them

Fixes #51.