added test and made port configurable
made port configurable
refactored