update error middleware; add new tests for messages