Add tests
Refactor controllers and input sanitizer