There is one function in this script to be tested. It could be modularized further to enable unit tests. Use mocks and table tests to test edge cases.