Refactor asum and test_asum