add csrf fix
Refactored tests into helpers