def test_extract_title():
    # Basic case
    assert extract_title("# Simple Title") == "Simple Title"
    
    # Extra spaces case
    assert extract_title("#     Extra Spaces    ") == "    Extra Spaces    "
    
    # Multiple lines case
    text = """# Main Title
    ## Subtitle
    Some content
    More content"""
    assert extract_title(text) == "Main Title"
    
    # Empty input
    try:
        extract_title("")
        assert False, "Empty input should raise exception"
    except Exception:
        assert True
        
    # Invalid headers
    try:
        extract_title("##Not a title\nJust some text")
        assert False, "Invalid header should raise exception"
    except Exception:
        assert True
