Added output parser, tests and a little refactoring