Fix #126

This pull request fixes mainly #126, and some other things along the way.

Tests added.
offtopic: I think we have a bug in this if clause for the case when `fname` isn't true and `ctype` is specified. Then "Content-Disposition" header will terminate headers section and "Content-Type" will be passed not as a header, but as a chunk of data.