fix constraints, add tests