Mobs won't show up next to you as long as you have sufficient lighting (lighting level 7 or more, torches produce light level 14). All you need to do to stop them spawning is to pop up a couple of torches in your bedroom and make sure to have a door (or block up a doorway) so that mobs that have spawned else-ware don't wander in to spoil your nap.
As a side not, you may sometimes get the error "can't sleep there are monsters nearby", this happens to me often while i'm sleeping in a cave I've made. It just means that either above, below or to the side of you there is a cave or opening where a mob has discovered you, just dig around a bit, have a bit of murder and then you can rest easy.
I hope this has helped, happy mining!