How do I construct a safe sleeping area in 1.5 version?

After extensive testing I have found out that the problem is with the level on which the door is in relation to the surrounding. Each door needs to have at least 4 blocks in each direction on the same level as the door itself.

0000000000000
001111XXXXXX0
001111X1111X0
001111X1BB1X0
001111D1111X0
001111X1111X0
001111X1111X0
001111X1111X0
001111XXXXXX0
0000000000000

0,1 - ground levels, X - wall, B - bed, D - door

enter image description here


I dug myself a tunnel into a huge rock formation, cleared out a small 3x3 room, lit it, and put down my bed, and was able to successfully sleep there. It looked like so:

#########
### . ###
D.  BB###
### . ###
#########

#= Wall, D=Door, .=Torch, B=Bed

The tunnel/doorway are 2 blocks high, and the 3x3 "room" is also 3 blocks high. The three torches are probably overkill, but I wanted to make sure it was brightly lit :)