Marginalization implemented with tests