Add parameter input validation, tests, minor refactoring to file layout