refactor ajax controller
fix strange failing test