"Worms are the simplest organisms to have a central nervous system, which includes a distinct brain that is connected to groups of neurons organized as nerve cords running along the length of its body. This more complicated nervous system allows worms to exhibit more complex forms of behavior. An anterior brain connected to a nerve cord is the basic design for all organisms with central nervous systems, from the earthworm on the hook to the human on the other end of the fishing rod. But although we can discern a separate brain in worms, it is not the case that the brain is the sole "commander" of the animal that the rest of the nervous system and body obeys. Indeed, even with its brain removed, worms are able to perform many types of behaviors, including locomotion, mating, burrowing, feeding, and even maze learning.(Bullock 1977) " http://faculty.ed.uiuc.edu/g-cziko/wm/05.html
If a worm is maze learning (and brainless at that) it has to be negotiating its enviroment emotively, so that it has an idea about which direction feels 'good' and which one feels 'bad', and it's also going to need a reliable, and accessible way of storing this feeling as a memory.It appears that even the most basic creatures with their brains removed still have an idea about what's right or wrong!