Added tests, updated code for indexed singleton.