Add tests and minor cleanup for javascript quick-sort

I would probably `slice` it when it's too small too, for consistency in the returned array.