Refactor stacktrace generation, add tests, fixes issues with file/line missing in php backtraces