refactoring + added test for constraint solver