refactor a bit MAPInference and add more unit-tests

@ppletscher, @iglesias I added a test for loss augmentation and a test for multiple states inference.