added unit tests and fixed bug that they uncovered; solver now working