More tests and fixes for bookkeeping. Handle constraints from different sources