Fix segfault with scope_lookup if the item is an object + added test