The Meaning of Life, the Universe, and Everything.
Are you trying to place a bed, while facing the wall, on the block next to the wall? Beds go in the direction you are looking in, and require two blocks to place. Yes and no, I think that the villager has to be awake for it to take the job. I may be wrong on that one. And for the last question, are you breaking the job block as soon as you don't see the villager taking it? For a villager to have a job, it has to have a claimed bed near the job block. Additionally, the villager does not take the job immediately. Rather, it has to go to the job block and claim it, which may take some time.
There's also the possibility of it being a nitwit, which doesn't work or trade with you at all, or let you change its profession. It wears a green robe.