more cleanup and error handling as I implement a real world client
fixed content type
updated tests and handle more edgecases