Refactor index route and tests