Unit tests, refactored cropping

Hi,

I've created some basic unit tests for use with PHPUnit, and added the config file for Travis.

More test will still need to be added whenever anyone has some spare time, but this should be a decent start.

The cropping has been refactored again, should be a lot easier to understand now.

Recommend tagging as 1.2.0 (composer config has been updated as such).

You'll also need to add the Travis service hook.