Fix output buffer error in phpunit>=4.2

Partial fix for #1262
Need improve exception handling. For now we are losing a stack trace and exception's class.