add exists check
make redirect statements testable
add missing tests