Added junit and refactored example into tests