Added tests to 36c7a819582b838b7bbab11d55ca3d991a587405

Refactored _deallocate_port method.