Satisfy Spec, Refactor

After re-reading the spec, implemented improved AJAX functionality such
that the spec if now completely satisfied. Slightly refactored some
code, improved tests.