Adding the index argument to the function argument in populateMap

Also adding tests (there should've been tests...)
does it make sense to have `index` as the typesig rather than `number`?
im not saying it must be changed, this might actually be clearer as a function signature... but want to check this was intentional