Added reasoner + tests; separated utility functions