brute force marginal inf and tests, minor refactoring