Correct a bug in Cop#keywords.

Fix for #159. 

In the old code we get stuck pushing and popping keywords when 'def'
is the last keyword in the list. Reworked the algorithm a bit.