Support/refactor indexjs

My first go at refactoring this module, which include cleaning up the way we construct the params object for the request constructor and such.

The main thing is that I relied heavily on the tests to prove this refactor was stable, but I'll rely on those who have a little more context to judge that.