add more tests, simplify new function