Add helper functions and their unit tests