refactor key setting, allow for explicit array indices
add an extra test