Er, this is a duplicate of which bug?
Maybe related to the fact that you can sleep when slimes are nearby, maybe they are somehow "peaceful" mobs in the code.
It's very frustrating, I have a little iron farm and now I have to suffocate all of the fail spawned iron golems... :|
Er, this is a duplicate of which bug?