improved tests and ajax function