added logging and tests, added 500 handler which doesnt have the desired effect.