I'd like to create a seamless pattern from the image below:

I can cut out a rectangle and attempt to tile it but it doesn't quite line up:

I know photomerge works really well for creating panoramas but I was wondering if there is a similar tool that works on layers instead of files? Failing that, what other ways could i go about doing this?