Adds benchmarks and unit tests for the function Co-authored-by: Rasmus Karlsson <rasmus.karlsson@pajlada.com>