Fill the recessed holes with wood putty. Also fill the nail holes on the trim pieces, door panels and the small seam along the sides of the bed box.
Hold the bed up and install some simple sliding bolts inside both bookcases. Drill a hole through the bookcase into the bed box, and screw them into place. Place the bolts underneath the shelves so they are completely out of sight.