I think there is a problem related to unit test logic.
If you are expecting a specific exception under certain inputs, you declare it as an expected exception. If you are just checking whether your function behaves properly and no exceptions are expected during this proper behavior, you just write it and if it throws any exception, your test fails.
Your code seems to be working properly, on the other hand, only checking no exceptions may not be the proper way for unit testing. In unit tests, generally you expect some outputs (expected values), you have some actual outputs (actual values) and you assert that expected and actual values are the same.