a little refactoring of content-type tidying up some complex methods
test fixes