added tests for closest bed and fixed identified bug