Refactoring

Added a function arity exception check, cleaned up some tests by using
it