Could you write unit tests for this function?