Improve calculator example
Refactor calculator example, cover edge cases