add unittests. move input validation function to separate module