The problem is when I specify a minimum amount of the order and I exclude from the coupon some categories.
When you set up a coupon like this, the only parameter that Prestashop considers is the minimum amount, even if that minimum amount is reached with products from excluded categories.
Let's take your example: the cart amount is 30€, but the minimum amount of 20€ should not be considered as reached, because the total of eligible products in the cart is only 10€.
The products from category B should not be counted, because they are excluded from the coupon.
This is the issue that I was talking about: considering the cart in the example you made, the coupon is considered valid when instead should not be valid.