Added argument error checking, updated unit tests