1. The same code works for me.. Maybe the goblin sprite has some weird collision polygon or an origin image point position? Try with a rectangular polygon and the image point in the middle.
2. You can use invisible sprites to limit movement. When enemy collides with such sprite, toggle its direction.