index: use secureRandom and add missing tests