My theory on loyalty in dogs is, who the dog sleeps beside is who the dog belongs to! I feel that if a dog is sleeping by the foot of your bed, or on the side of the chair where you sit at the kitchen table or by your lazyboy, you are who the dog belongs to, whether you like it or not!
I personally have had a dog that slept by my bed, although not the entire night, but she made it look like it was the entire night. She was so cute, she would sleep by my bed until I fell asleep and the leave and go on the comfy couch in the living room, but she made sure she was back in my room before I woke up, to make it look like she was by my side all the while. She was a good dog, there was no doubt about it, she was my dog.
Now, we have Gracie. She has yet to choose who she will be most loyal to, but judging by my theory it won't be me. She does not sleep in or around my room. I feel sad about that, but there is nothing I can do but love her as is.