In a perfect world, you would have a USB-serial (like FTDI) adapter. You would use that to communicast from your favorite PC program to the ESP8266 just to make sure it is talking properly - that is, all of the AT commands work.
You could also try this:
Most likely, your Arduino sketch on the Mega is to blame ... but you have to prove it by testing.