Improved AJAX mocking in tests