Please also add unit tests for the modified and newly added functions if possible.