BUG: test and fix a bug in the function that computes marginal distributions at nodes