From looking over Kernel::System::Ticket's TicketMerge method it looks as though your code is fine, it returns false if any issue arises otherwise true. You mention that the TicketMerge method fails and outputs various error messages, could you possibly provide the complete output as these messages may provide important clues. As it stands, the behaviour you report doesn't correlate with the modules code.