Added tests for formula evaluation

* Minor fixes as detected by the tests