It seems image() loses its layer attribute.
Code Snippet (if applicable) to Reproduce Problem:
It should output 5.
It outputs -1.
When does the problem NOT occur?
That snippet seems to output the correct layer when not defining an icon.