Added some validations and unit tests