Adding the index argument to the function argument in populateMap

Also adding tests (there should've been tests...)