refactor convert_idx_to_tuple

Also unit test is added.

Signed-off-by: Heiko Thiery <heiko.thiery@kontron.com>