Fix behavior of preflight request methods
Add tests for helper functions