The bug was caused by a weird behaviour in test_if_group_changed, not returning true when testing for the first time after initializing the Cached_item list.