fix issues with writeResponse and unit tests