Improved example and refactored into module mode with tests.