added ajax to method and adjusted tests