added test for serving index to root and did some refactoring