Rewrote the helper and added tests for it.