Add some basic PHPUnit tests

Required slight tweaks to code, to allow it to be called repeatedly
Added travis config file