Cleanup code, add 405 handling, route sanitization and more tests