Add tests

I just pick the work of @ebryn, update Qunit, and rebase against master.