Add argument validation and enhance test cases