Litter boxes need to be placed a minimum of one foot away from each wall. This creates multiple "escape routes". Your cat feels vulnerable when it is using the litter box - he can't help it, it's wired in his DNA. Predators can sneak up on a cat concentration on urinating.
When I learned this in school I said to myself "Tabasco uses the litter box just fine - he never looks 'stressed out' in there" but when I uncovered the box and moved it away from the wall I noticed a change in him. He wasn't in such a hurry to get out of the box, and he is much more likely to cover his "droppings".