Updates conditional, replaces die() with Exception

Adds phpunit as dev dependency and adds a unit test