Removed restrictions on adding headers after connection has started

#2142
Added test to check that the user can set request headers after the connection has started

#2504
Made some formatting changes

#2504