]> git.r.bdr.sh - rbdr/mobius/blobdiff - hotline/transaction_handlers_test.go
Extensive refactor and clean up
[rbdr/mobius] / hotline / transaction_handlers_test.go
index 9ea4a0a11f72afe28c31a74e6fb35de567445a1d..610e11399f7516467b844f0fe053598cc5596f76 100644 (file)
@@ -2,7 +2,6 @@ package hotline
 
 import (
        "errors"
-       "fmt"
        "github.com/stretchr/testify/assert"
        "github.com/stretchr/testify/mock"
        "io"
@@ -17,13 +16,12 @@ import (
 func TestHandleSetChatSubject(t *testing.T) {
        type args struct {
                cc *ClientConn
-               t  *Transaction
+               t  Transaction
        }
        tests := []struct {
-               name    string
-               args    args
-               want    []Transaction
-               wantErr bool
+               name string
+               args args
+               want []Transaction
        }{
                {
                        name: "sends chat subject to private chat members",
@@ -31,42 +29,66 @@ func TestHandleSetChatSubject(t *testing.T) {
                                cc: &ClientConn{
                                        UserName: []byte{0x00, 0x01},
                                        Server: &Server{
-                                               PrivateChats: map[uint32]*PrivateChat{
-                                                       uint32(1): {
-                                                               Subject: "unset",
-                                                               ClientConn: map[uint16]*ClientConn{
-                                                                       uint16(1): {
-                                                                               Account: &Account{
-                                                                                       Access: accessBitmap{255, 255, 255, 255, 255, 255, 255, 255},
-                                                                               },
-                                                                               ID: &[]byte{0, 1},
+                                               ChatMgr: func() *MockChatManager {
+                                                       m := MockChatManager{}
+                                                       m.On("Members", ChatID{0x0, 0x0, 0x0, 0x1}).Return([]*ClientConn{
+                                                               {
+                                                                       Account: &Account{
+                                                                               Access: accessBitmap{255, 255, 255, 255, 255, 255, 255, 255},
                                                                        },
-                                                                       uint16(2): {
-                                                                               Account: &Account{
-                                                                                       Access: accessBitmap{255, 255, 255, 255, 255, 255, 255, 255},
-                                                                               },
-                                                                               ID: &[]byte{0, 2},
+                                                                       ID: [2]byte{0, 1},
+                                                               },
+                                                               {
+                                                                       Account: &Account{
+                                                                               Access: accessBitmap{255, 255, 255, 255, 255, 255, 255, 255},
                                                                        },
+                                                                       ID: [2]byte{0, 2},
                                                                },
-                                                       },
-                                               },
-                                               Clients: map[uint16]*ClientConn{
-                                                       uint16(1): {
-                                                               Account: &Account{
-                                                                       Access: accessBitmap{255, 255, 255, 255, 255, 255, 255, 255},
+                                                       })
+                                                       m.On("SetSubject", ChatID{0x0, 0x0, 0x0, 0x1}, "Test Subject")
+                                                       return &m
+                                               }(),
+                                               //PrivateChats: map[[4]byte]*PrivateChat{
+                                               //      [4]byte{0, 0, 0, 1}: {
+                                               //              Subject: "unset",
+                                               //              ClientConn: map[[2]byte]*ClientConn{
+                                               //                      [2]byte{0, 1}: {
+                                               //                              Account: &Account{
+                                               //                                      Access: accessBitmap{255, 255, 255, 255, 255, 255, 255, 255},
+                                               //                              },
+                                               //                              ID: [2]byte{0, 1},
+                                               //                      },
+                                               //                      [2]byte{0, 2}: {
+                                               //                              Account: &Account{
+                                               //                                      Access: accessBitmap{255, 255, 255, 255, 255, 255, 255, 255},
+                                               //                              },
+                                               //                              ID: [2]byte{0, 2},
+                                               //                      },
+                                               //              },
+                                               //      },
+                                               //},
+                                               ClientMgr: func() *MockClientMgr {
+                                                       m := MockClientMgr{}
+                                                       m.On("List").Return([]*ClientConn{
+                                                               {
+                                                                       Account: &Account{
+                                                                               Access: accessBitmap{255, 255, 255, 255, 255, 255, 255, 255},
+                                                                       },
+                                                                       ID: [2]byte{0, 1},
                                                                },
-                                                               ID: &[]byte{0, 1},
-                                                       },
-                                                       uint16(2): {
-                                                               Account: &Account{
-                                                                       Access: accessBitmap{255, 255, 255, 255, 255, 255, 255, 255},
+                                                               {
+                                                                       Account: &Account{
+                                                                               Access: accessBitmap{255, 255, 255, 255, 255, 255, 255, 255},
+                                                                       },
+                                                                       ID: [2]byte{0, 2},
                                                                },
-                                                               ID: &[]byte{0, 2},
                                                        },
-                                               },
+                                                       )
+                                                       return &m
+                                               }(),
                                        },
                                },
-                               t: &Transaction{
+                               t: Transaction{
                                        Type: [2]byte{0, 0x6a},
                                        ID:   [4]byte{0, 0, 0, 1},
                                        Fields: []Field{
@@ -77,7 +99,7 @@ func TestHandleSetChatSubject(t *testing.T) {
                        },
                        want: []Transaction{
                                {
-                                       clientID: &[]byte{0, 1},
+                                       clientID: [2]byte{0, 1},
                                        Type:     [2]byte{0, 0x77},
                                        Fields: []Field{
                                                NewField(FieldChatID, []byte{0, 0, 0, 1}),
@@ -85,7 +107,7 @@ func TestHandleSetChatSubject(t *testing.T) {
                                        },
                                },
                                {
-                                       clientID: &[]byte{0, 2},
+                                       clientID: [2]byte{0, 2},
                                        Type:     [2]byte{0, 0x77},
                                        Fields: []Field{
                                                NewField(FieldChatID, []byte{0, 0, 0, 1}),
@@ -93,16 +115,11 @@ func TestHandleSetChatSubject(t *testing.T) {
                                        },
                                },
                        },
-                       wantErr: false,
                },
        }
        for _, tt := range tests {
                t.Run(tt.name, func(t *testing.T) {
-                       got, err := HandleSetChatSubject(tt.args.cc, tt.args.t)
-                       if (err != nil) != tt.wantErr {
-                               t.Errorf("HandleSetChatSubject() error = %v, wantErr %v", err, tt.wantErr)
-                               return
-                       }
+                       got := HandleSetChatSubject(tt.args.cc, &tt.args.t)
                        if !tranAssertEqual(t, tt.want, got) {
                                t.Errorf("HandleSetChatSubject() got = %v, want %v", got, tt.want)
                        }
@@ -113,61 +130,59 @@ func TestHandleSetChatSubject(t *testing.T) {
 func TestHandleLeaveChat(t *testing.T) {
        type args struct {
                cc *ClientConn
-               t  *Transaction
+               t  Transaction
        }
        tests := []struct {
-               name    string
-               args    args
-               want    []Transaction
-               wantErr bool
+               name string
+               args args
+               want []Transaction
        }{
                {
-                       name: "returns expected transactions",
+                       name: "when client 2 leaves chat",
                        args: args{
                                cc: &ClientConn{
-                                       ID: &[]byte{0, 2},
+                                       ID: [2]byte{0, 2},
                                        Server: &Server{
-                                               PrivateChats: map[uint32]*PrivateChat{
-                                                       uint32(1): {
-                                                               ClientConn: map[uint16]*ClientConn{
-                                                                       uint16(1): {
-                                                                               Account: &Account{
-                                                                                       Access: accessBitmap{255, 255, 255, 255, 255, 255, 255, 255},
-                                                                               },
-                                                                               ID: &[]byte{0, 1},
-                                                                       },
-                                                                       uint16(2): {
-                                                                               Account: &Account{
-                                                                                       Access: accessBitmap{255, 255, 255, 255, 255, 255, 255, 255},
-                                                                               },
-                                                                               ID: &[]byte{0, 2},
+                                               ChatMgr: func() *MockChatManager {
+                                                       m := MockChatManager{}
+                                                       m.On("Members", ChatID{0x0, 0x0, 0x0, 0x1}).Return([]*ClientConn{
+                                                               {
+                                                                       Account: &Account{
+                                                                               Access: accessBitmap{255, 255, 255, 255, 255, 255, 255, 255},
                                                                        },
+                                                                       ID: [2]byte{0, 1},
                                                                },
-                                                       },
-                                               },
-                                               Clients: map[uint16]*ClientConn{
-                                                       uint16(1): {
-                                                               Account: &Account{
-                                                                       Access: accessBitmap{255, 255, 255, 255, 255, 255, 255, 255},
+                                                       })
+                                                       m.On("Leave", ChatID{0x0, 0x0, 0x0, 0x1}, [2]uint8{0x0, 0x2})
+                                                       m.On("GetSubject").Return("unset")
+                                                       return &m
+                                               }(),
+                                               ClientMgr: func() *MockClientMgr {
+                                                       m := MockClientMgr{}
+                                                       m.On("Get").Return([]*ClientConn{
+                                                               {
+                                                                       Account: &Account{
+                                                                               Access: accessBitmap{255, 255, 255, 255, 255, 255, 255, 255},
+                                                                       },
+                                                                       ID: [2]byte{0, 1},
                                                                },
-                                                               ID: &[]byte{0, 1},
-                                                       },
-                                                       uint16(2): {
-                                                               Account: &Account{
-                                                                       Access: accessBitmap{255, 255, 255, 255, 255, 255, 255, 255},
+                                                               {
+                                                                       Account: &Account{
+                                                                               Access: accessBitmap{255, 255, 255, 255, 255, 255, 255, 255},
+                                                                       },
+                                                                       ID: [2]byte{0, 2},
                                                                },
-                                                               ID: &[]byte{0, 2},
                                                        },
-                                               },
+                                                       )
+                                                       return &m
+                                               }(),
                                        },
                                },
-                               t: NewTransaction(TranDeleteUser, nil, NewField(FieldChatID, []byte{0, 0, 0, 1})),
+                               t: NewTransaction(TranDeleteUser, [2]byte{}, NewField(FieldChatID, []byte{0, 0, 0, 1})),
                        },
                        want: []Transaction{
                                {
-                                       clientID: &[]byte{0, 1},
-                                       Flags:    0x00,
-                                       IsReply:  0x00,
+                                       clientID: [2]byte{0, 1},
                                        Type:     [2]byte{0, 0x76},
                                        Fields: []Field{
                                                NewField(FieldChatID, []byte{0, 0, 0, 1}),
@@ -175,16 +190,11 @@ func TestHandleLeaveChat(t *testing.T) {
                                        },
                                },
                        },
-                       wantErr: false,
                },
        }
        for _, tt := range tests {
                t.Run(tt.name, func(t *testing.T) {
-                       got, err := HandleLeaveChat(tt.args.cc, tt.args.t)
-                       if (err != nil) != tt.wantErr {
-                               t.Errorf("HandleLeaveChat() error = %v, wantErr %v", err, tt.wantErr)
-                               return
-                       }
+                       got := HandleLeaveChat(tt.args.cc, &tt.args.t)
                        if !tranAssertEqual(t, tt.want, got) {
                                t.Errorf("HandleLeaveChat() got = %v, want %v", got, tt.want)
                        }
@@ -195,42 +205,45 @@ func TestHandleLeaveChat(t *testing.T) {
 func TestHandleGetUserNameList(t *testing.T) {
        type args struct {
                cc *ClientConn
-               t  *Transaction
+               t  Transaction
        }
        tests := []struct {
-               name    string
-               args    args
-               want    []Transaction
-               wantErr bool
+               name string
+               args args
+               want []Transaction
        }{
                {
                        name: "replies with userlist transaction",
                        args: args{
                                cc: &ClientConn{
-
-                                       ID: &[]byte{1, 1},
+                                       ID: [2]byte{0, 1},
                                        Server: &Server{
-                                               Clients: map[uint16]*ClientConn{
-                                                       uint16(1): {
-                                                               ID:       &[]byte{0, 1},
-                                                               Icon:     []byte{0, 2},
-                                                               Flags:    []byte{0, 3},
-                                                               UserName: []byte{0, 4},
-                                                       },
-                                                       uint16(2): {
-                                                               ID:       &[]byte{0, 2},
-                                                               Icon:     []byte{0, 2},
-                                                               Flags:    []byte{0, 3},
-                                                               UserName: []byte{0, 4},
+                                               ClientMgr: func() *MockClientMgr {
+                                                       m := MockClientMgr{}
+                                                       m.On("List").Return([]*ClientConn{
+                                                               {
+                                                                       ID:       [2]byte{0, 1},
+                                                                       Icon:     []byte{0, 2},
+                                                                       Flags:    [2]byte{0, 3},
+                                                                       UserName: []byte{0, 4},
+                                                               },
+                                                               {
+                                                                       ID:       [2]byte{0, 2},
+                                                                       Icon:     []byte{0, 2},
+                                                                       Flags:    [2]byte{0, 3},
+                                                                       UserName: []byte{0, 4},
+                                                               },
                                                        },
-                                               },
+                                                       )
+                                                       return &m
+                                               }(),
                                        },
                                },
-                               t: &Transaction{},
+                               t: Transaction{},
                        },
                        want: []Transaction{
                                {
-                                       clientID: &[]byte{1, 1},
+                                       clientID: [2]byte{0, 1},
                                        IsReply:  0x01,
                                        Fields: []Field{
                                                NewField(
@@ -244,16 +257,11 @@ func TestHandleGetUserNameList(t *testing.T) {
                                        },
                                },
                        },
-                       wantErr: false,
                },
        }
        for _, tt := range tests {
                t.Run(tt.name, func(t *testing.T) {
-                       got, err := HandleGetUserNameList(tt.args.cc, tt.args.t)
-                       if (err != nil) != tt.wantErr {
-                               t.Errorf("HandleGetUserNameList() error = %v, wantErr %v", err, tt.wantErr)
-                               return
-                       }
+                       got := HandleGetUserNameList(tt.args.cc, &tt.args.t)
                        assert.Equal(t, tt.want, got)
                })
        }
@@ -262,13 +270,12 @@ func TestHandleGetUserNameList(t *testing.T) {
 func TestHandleChatSend(t *testing.T) {
        type args struct {
                cc *ClientConn
-               t  *Transaction
+               t  Transaction
        }
        tests := []struct {
-               name    string
-               args    args
-               want    []Transaction
-               wantErr bool
+               name string
+               args args
+               want []Transaction
        }{
                {
                        name: "sends chat msg transaction to all clients",
@@ -277,29 +284,34 @@ func TestHandleChatSend(t *testing.T) {
                                        Account: &Account{
                                                Access: func() accessBitmap {
                                                        var bits accessBitmap
-                                                       bits.Set(accessSendChat)
+                                                       bits.Set(AccessSendChat)
                                                        return bits
                                                }(),
                                        },
                                        UserName: []byte{0x00, 0x01},
                                        Server: &Server{
-                                               Clients: map[uint16]*ClientConn{
-                                                       uint16(1): {
-                                                               Account: &Account{
-                                                                       Access: accessBitmap{255, 255, 255, 255, 255, 255, 255, 255},
+                                               ClientMgr: func() *MockClientMgr {
+                                                       m := MockClientMgr{}
+                                                       m.On("List").Return([]*ClientConn{
+                                                               {
+                                                                       Account: &Account{
+                                                                               Access: accessBitmap{255, 255, 255, 255, 255, 255, 255, 255},
+                                                                       },
+                                                                       ID: [2]byte{0, 1},
                                                                },
-                                                               ID: &[]byte{0, 1},
-                                                       },
-                                                       uint16(2): {
-                                                               Account: &Account{
-                                                                       Access: accessBitmap{255, 255, 255, 255, 255, 255, 255, 255},
+                                                               {
+                                                                       Account: &Account{
+                                                                               Access: accessBitmap{255, 255, 255, 255, 255, 255, 255, 255},
+                                                                       },
+                                                                       ID: [2]byte{0, 2},
                                                                },
-                                                               ID: &[]byte{0, 2},
                                                        },
-                                               },
+                                                       )
+                                                       return &m
+                                               }(),
                                        },
                                },
-                               t: &Transaction{
+                               t: Transaction{
                                        Fields: []Field{
                                                NewField(FieldData, []byte("hai")),
                                        },
@@ -307,7 +319,7 @@ func TestHandleChatSend(t *testing.T) {
                        },
                        want: []Transaction{
                                {
-                                       clientID: &[]byte{0, 1},
+                                       clientID: [2]byte{0, 1},
                                        Flags:    0x00,
                                        IsReply:  0x00,
                                        Type:     [2]byte{0, 0x6a},
@@ -316,7 +328,7 @@ func TestHandleChatSend(t *testing.T) {
                                        },
                                },
                                {
-                                       clientID: &[]byte{0, 2},
+                                       clientID: [2]byte{0, 2},
                                        Flags:    0x00,
                                        IsReply:  0x00,
                                        Type:     [2]byte{0, 0x6a},
@@ -325,38 +337,42 @@ func TestHandleChatSend(t *testing.T) {
                                        },
                                },
                        },
-                       wantErr: false,
                },
                {
-                       name: "treats Chat ID 00 00 00 00 as a public chat message",
+                       name: "treats Chat Type 00 00 00 00 as a public chat message",
                        args: args{
                                cc: &ClientConn{
                                        Account: &Account{
                                                Access: func() accessBitmap {
                                                        var bits accessBitmap
-                                                       bits.Set(accessSendChat)
+                                                       bits.Set(AccessSendChat)
                                                        return bits
                                                }(),
                                        },
                                        UserName: []byte{0x00, 0x01},
                                        Server: &Server{
-                                               Clients: map[uint16]*ClientConn{
-                                                       uint16(1): {
-                                                               Account: &Account{
-                                                                       Access: accessBitmap{255, 255, 255, 255, 255, 255, 255, 255},
+                                               ClientMgr: func() *MockClientMgr {
+                                                       m := MockClientMgr{}
+                                                       m.On("List").Return([]*ClientConn{
+                                                               {
+                                                                       Account: &Account{
+                                                                               Access: accessBitmap{255, 255, 255, 255, 255, 255, 255, 255},
+                                                                       },
+                                                                       ID: [2]byte{0, 1},
                                                                },
-                                                               ID: &[]byte{0, 1},
-                                                       },
-                                                       uint16(2): {
-                                                               Account: &Account{
-                                                                       Access: accessBitmap{255, 255, 255, 255, 255, 255, 255, 255},
+                                                               {
+                                                                       Account: &Account{
+                                                                               Access: accessBitmap{255, 255, 255, 255, 255, 255, 255, 255},
+                                                                       },
+                                                                       ID: [2]byte{0, 2},
                                                                },
-                                                               ID: &[]byte{0, 2},
                                                        },
-                                               },
+                                                       )
+                                                       return &m
+                                               }(),
                                        },
                                },
-                               t: &Transaction{
+                               t: Transaction{
                                        Fields: []Field{
                                                NewField(FieldData, []byte("hai")),
                                                NewField(FieldChatID, []byte{0, 0, 0, 0}),
@@ -365,21 +381,20 @@ func TestHandleChatSend(t *testing.T) {
                        },
                        want: []Transaction{
                                {
-                                       clientID: &[]byte{0, 1},
+                                       clientID: [2]byte{0, 1},
                                        Type:     [2]byte{0, 0x6a},
                                        Fields: []Field{
                                                NewField(FieldData, []byte{0x0d, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x00, 0x01, 0x3a, 0x20, 0x20, 0x68, 0x61, 0x69}),
                                        },
                                },
                                {
-                                       clientID: &[]byte{0, 2},
+                                       clientID: [2]byte{0, 2},
                                        Type:     [2]byte{0, 0x6a},
                                        Fields: []Field{
                                                NewField(FieldData, []byte{0x0d, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x00, 0x01, 0x3a, 0x20, 0x20, 0x68, 0x61, 0x69}),
                                        },
                                },
                        },
-                       wantErr: false,
                },
                {
                        name: "when user does not have required permission",
@@ -392,11 +407,11 @@ func TestHandleChatSend(t *testing.T) {
                                                }(),
                                        },
                                        Server: &Server{
-                                               Accounts: map[string]*Account{},
+                                               //Accounts: map[string]*Account{},
                                        },
                                },
                                t: NewTransaction(
-                                       TranChatSend, &[]byte{0, 1},
+                                       TranChatSend, [2]byte{0, 1},
                                        NewField(FieldData, []byte("hai")),
                                ),
                        },
@@ -409,7 +424,6 @@ func TestHandleChatSend(t *testing.T) {
                                        },
                                },
                        },
-                       wantErr: false,
                },
                {
                        name: "sends chat msg as emote if FieldChatOptions is set to 1",
@@ -418,29 +432,34 @@ func TestHandleChatSend(t *testing.T) {
                                        Account: &Account{
                                                Access: func() accessBitmap {
                                                        var bits accessBitmap
-                                                       bits.Set(accessSendChat)
+                                                       bits.Set(AccessSendChat)
                                                        return bits
                                                }(),
                                        },
                                        UserName: []byte("Testy McTest"),
                                        Server: &Server{
-                                               Clients: map[uint16]*ClientConn{
-                                                       uint16(1): {
-                                                               Account: &Account{
-                                                                       Access: accessBitmap{255, 255, 255, 255, 255, 255, 255, 255},
+                                               ClientMgr: func() *MockClientMgr {
+                                                       m := MockClientMgr{}
+                                                       m.On("List").Return([]*ClientConn{
+                                                               {
+                                                                       Account: &Account{
+                                                                               Access: accessBitmap{255, 255, 255, 255, 255, 255, 255, 255},
+                                                                       },
+                                                                       ID: [2]byte{0, 1},
                                                                },
-                                                               ID: &[]byte{0, 1},
-                                                       },
-                                                       uint16(2): {
-                                                               Account: &Account{
-                                                                       Access: accessBitmap{255, 255, 255, 255, 255, 255, 255, 255},
+                                                               {
+                                                                       Account: &Account{
+                                                                               Access: accessBitmap{255, 255, 255, 255, 255, 255, 255, 255},
+                                                                       },
+                                                                       ID: [2]byte{0, 2},
                                                                },
-                                                               ID: &[]byte{0, 2},
                                                        },
-                                               },
+                                                       )
+                                                       return &m
+                                               }(),
                                        },
                                },
-                               t: &Transaction{
+                               t: Transaction{
                                        Fields: []Field{
                                                NewField(FieldData, []byte("performed action")),
                                                NewField(FieldChatOptions, []byte{0x00, 0x01}),
@@ -449,7 +468,7 @@ func TestHandleChatSend(t *testing.T) {
                        },
                        want: []Transaction{
                                {
-                                       clientID: &[]byte{0, 1},
+                                       clientID: [2]byte{0, 1},
                                        Flags:    0x00,
                                        IsReply:  0x00,
                                        Type:     [2]byte{0, 0x6a},
@@ -458,7 +477,7 @@ func TestHandleChatSend(t *testing.T) {
                                        },
                                },
                                {
-                                       clientID: &[]byte{0, 2},
+                                       clientID: [2]byte{0, 2},
                                        Flags:    0x00,
                                        IsReply:  0x00,
                                        Type:     [2]byte{0, 0x6a},
@@ -467,7 +486,6 @@ func TestHandleChatSend(t *testing.T) {
                                        },
                                },
                        },
-                       wantErr: false,
                },
                {
                        name: "does not send chat msg as emote if FieldChatOptions is set to 0",
@@ -476,29 +494,34 @@ func TestHandleChatSend(t *testing.T) {
                                        Account: &Account{
                                                Access: func() accessBitmap {
                                                        var bits accessBitmap
-                                                       bits.Set(accessSendChat)
+                                                       bits.Set(AccessSendChat)
                                                        return bits
                                                }(),
                                        },
                                        UserName: []byte("Testy McTest"),
                                        Server: &Server{
-                                               Clients: map[uint16]*ClientConn{
-                                                       uint16(1): {
-                                                               Account: &Account{
-                                                                       Access: accessBitmap{255, 255, 255, 255, 255, 255, 255, 255},
+                                               ClientMgr: func() *MockClientMgr {
+                                                       m := MockClientMgr{}
+                                                       m.On("List").Return([]*ClientConn{
+                                                               {
+                                                                       Account: &Account{
+                                                                               Access: accessBitmap{255, 255, 255, 255, 255, 255, 255, 255},
+                                                                       },
+                                                                       ID: [2]byte{0, 1},
                                                                },
-                                                               ID: &[]byte{0, 1},
-                                                       },
-                                                       uint16(2): {
-                                                               Account: &Account{
-                                                                       Access: accessBitmap{255, 255, 255, 255, 255, 255, 255, 255},
+                                                               {
+                                                                       Account: &Account{
+                                                                               Access: accessBitmap{255, 255, 255, 255, 255, 255, 255, 255},
+                                                                       },
+                                                                       ID: [2]byte{0, 2},
                                                                },
-                                                               ID: &[]byte{0, 2},
                                                        },
-                                               },
+                                                       )
+                                                       return &m
+                                               }(),
                                        },
                                },
-                               t: &Transaction{
+                               t: Transaction{
                                        Fields: []Field{
                                                NewField(FieldData, []byte("hello")),
                                                NewField(FieldChatOptions, []byte{0x00, 0x00}),
@@ -507,55 +530,58 @@ func TestHandleChatSend(t *testing.T) {
                        },
                        want: []Transaction{
                                {
-                                       clientID: &[]byte{0, 1},
+                                       clientID: [2]byte{0, 1},
                                        Type:     [2]byte{0, 0x6a},
                                        Fields: []Field{
                                                NewField(FieldData, []byte("\r Testy McTest:  hello")),
                                        },
                                },
                                {
-                                       clientID: &[]byte{0, 2},
+                                       clientID: [2]byte{0, 2},
                                        Type:     [2]byte{0, 0x6a},
                                        Fields: []Field{
                                                NewField(FieldData, []byte("\r Testy McTest:  hello")),
                                        },
                                },
                        },
-                       wantErr: false,
                },
                {
-                       name: "only sends chat msg to clients with accessReadChat permission",
+                       name: "only sends chat msg to clients with AccessReadChat permission",
                        args: args{
                                cc: &ClientConn{
                                        Account: &Account{
                                                Access: func() accessBitmap {
                                                        var bits accessBitmap
-                                                       bits.Set(accessSendChat)
+                                                       bits.Set(AccessSendChat)
                                                        return bits
                                                }(),
                                        },
                                        UserName: []byte{0x00, 0x01},
                                        Server: &Server{
-                                               Clients: map[uint16]*ClientConn{
-                                                       uint16(1): {
-                                                               Account: &Account{
-                                                                       Access: func() accessBitmap {
-                                                                               var bits accessBitmap
-                                                                               bits.Set(accessReadChat)
-                                                                               return bits
-                                                                       }()},
-                                                               ID: &[]byte{0, 1},
-                                                       },
-                                                       uint16(2): {
-                                                               Account: &Account{
-                                                                       Access: accessBitmap{0, 0, 0, 0, 0, 0, 0, 0},
+                                               ClientMgr: func() *MockClientMgr {
+                                                       m := MockClientMgr{}
+                                                       m.On("List").Return([]*ClientConn{
+                                                               {
+                                                                       Account: &Account{
+                                                                               Access: func() accessBitmap {
+                                                                                       var bits accessBitmap
+                                                                                       bits.Set(AccessReadChat)
+                                                                                       return bits
+                                                                               }(),
+                                                                       },
+                                                                       ID: [2]byte{0, 1},
+                                                               },
+                                                               {
+                                                                       Account: &Account{},
+                                                                       ID:      [2]byte{0, 2},
                                                                },
-                                                               ID: &[]byte{0, 2},
                                                        },
-                                               },
+                                                       )
+                                                       return &m
+                                               }(),
                                        },
                                },
-                               t: &Transaction{
+                               t: Transaction{
                                        Fields: []Field{
                                                NewField(FieldData, []byte("hai")),
                                        },
@@ -563,14 +589,13 @@ func TestHandleChatSend(t *testing.T) {
                        },
                        want: []Transaction{
                                {
-                                       clientID: &[]byte{0, 1},
+                                       clientID: [2]byte{0, 1},
                                        Type:     [2]byte{0, 0x6a},
                                        Fields: []Field{
                                                NewField(FieldData, []byte{0x0d, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x00, 0x01, 0x3a, 0x20, 0x20, 0x68, 0x61, 0x69}),
                                        },
                                },
                        },
-                       wantErr: false,
                },
                {
                        name: "only sends private chat msg to members of private chat",
@@ -579,47 +604,53 @@ func TestHandleChatSend(t *testing.T) {
                                        Account: &Account{
                                                Access: func() accessBitmap {
                                                        var bits accessBitmap
-                                                       bits.Set(accessSendChat)
+                                                       bits.Set(AccessSendChat)
                                                        return bits
                                                }(),
                                        },
                                        UserName: []byte{0x00, 0x01},
                                        Server: &Server{
-                                               PrivateChats: map[uint32]*PrivateChat{
-                                                       uint32(1): {
-                                                               ClientConn: map[uint16]*ClientConn{
-                                                                       uint16(1): {
-                                                                               ID: &[]byte{0, 1},
-                                                                       },
-                                                                       uint16(2): {
-                                                                               ID: &[]byte{0, 2},
-                                                                       },
+                                               ChatMgr: func() *MockChatManager {
+                                                       m := MockChatManager{}
+                                                       m.On("Members", ChatID{0x0, 0x0, 0x0, 0x1}).Return([]*ClientConn{
+                                                               {
+                                                                       ID: [2]byte{0, 1},
                                                                },
-                                                       },
-                                               },
-                                               Clients: map[uint16]*ClientConn{
-                                                       uint16(1): {
-                                                               Account: &Account{
-                                                                       Access: accessBitmap{255, 255, 255, 255, 255, 255, 255, 255},
+                                                               {
+                                                                       ID: [2]byte{0, 2},
                                                                },
-                                                               ID: &[]byte{0, 1},
-                                                       },
-                                                       uint16(2): {
-                                                               Account: &Account{
-                                                                       Access: accessBitmap{0, 0, 0, 0, 0, 0, 0, 0},
+                                                       })
+                                                       m.On("GetSubject").Return("unset")
+                                                       return &m
+                                               }(),
+                                               ClientMgr: func() *MockClientMgr {
+                                                       m := MockClientMgr{}
+                                                       m.On("List").Return([]*ClientConn{
+                                                               {
+                                                                       Account: &Account{
+                                                                               Access: accessBitmap{255, 255, 255, 255, 255, 255, 255, 255},
+                                                                       },
+                                                                       ID: [2]byte{0, 1},
                                                                },
-                                                               ID: &[]byte{0, 2},
-                                                       },
-                                                       uint16(3): {
-                                                               Account: &Account{
-                                                                       Access: accessBitmap{0, 0, 0, 0, 0, 0, 0, 0},
+                                                               {
+                                                                       Account: &Account{
+                                                                               Access: accessBitmap{0, 0, 0, 0, 0, 0, 0, 0},
+                                                                       },
+                                                                       ID: [2]byte{0, 2},
+                                                               },
+                                                               {
+                                                                       Account: &Account{
+                                                                               Access: accessBitmap{0, 0, 0, 0, 0, 0, 0, 0},
+                                                                       },
+                                                                       ID: [2]byte{0, 3},
                                                                },
-                                                               ID: &[]byte{0, 3},
                                                        },
-                                               },
+                                                       )
+                                                       return &m
+                                               }(),
                                        },
                                },
-                               t: &Transaction{
+                               t: Transaction{
                                        Fields: []Field{
                                                NewField(FieldData, []byte("hai")),
                                                NewField(FieldChatID, []byte{0, 0, 0, 1}),
@@ -628,7 +659,7 @@ func TestHandleChatSend(t *testing.T) {
                        },
                        want: []Transaction{
                                {
-                                       clientID: &[]byte{0, 1},
+                                       clientID: [2]byte{0, 1},
                                        Type:     [2]byte{0, 0x6a},
                                        Fields: []Field{
                                                NewField(FieldChatID, []byte{0, 0, 0, 1}),
@@ -636,7 +667,7 @@ func TestHandleChatSend(t *testing.T) {
                                        },
                                },
                                {
-                                       clientID: &[]byte{0, 2},
+                                       clientID: [2]byte{0, 2},
                                        Type:     [2]byte{0, 0x6a},
                                        Fields: []Field{
                                                NewField(FieldChatID, []byte{0, 0, 0, 1}),
@@ -644,17 +675,11 @@ func TestHandleChatSend(t *testing.T) {
                                        },
                                },
                        },
-                       wantErr: false,
                },
        }
        for _, tt := range tests {
                t.Run(tt.name, func(t *testing.T) {
-                       got, err := HandleChatSend(tt.args.cc, tt.args.t)
-
-                       if (err != nil) != tt.wantErr {
-                               t.Errorf("HandleChatSend() error = %v, wantErr %v", err, tt.wantErr)
-                               return
-                       }
+                       got := HandleChatSend(tt.args.cc, &tt.args.t)
                        tranAssertEqual(t, tt.want, got)
                })
        }
@@ -663,22 +688,21 @@ func TestHandleChatSend(t *testing.T) {
 func TestHandleGetFileInfo(t *testing.T) {
        type args struct {
                cc *ClientConn
-               t  *Transaction
+               t  Transaction
        }
        tests := []struct {
                name    string
                args    args
                wantRes []Transaction
-               wantErr bool
        }{
                {
                        name: "returns expected fields when a valid file is requested",
                        args: args{
                                cc: &ClientConn{
-                                       ID: &[]byte{0x00, 0x01},
+                                       ID: [2]byte{0x00, 0x01},
                                        Server: &Server{
                                                FS: &OSFileStore{},
-                                               Config: &Config{
+                                               Config: Config{
                                                        FileRoot: func() string {
                                                                path, _ := os.Getwd()
                                                                return filepath.Join(path, "/test/config/Files")
@@ -687,14 +711,14 @@ func TestHandleGetFileInfo(t *testing.T) {
                                        },
                                },
                                t: NewTransaction(
-                                       TranGetFileInfo, nil,
+                                       TranGetFileInfo, [2]byte{},
                                        NewField(FieldFileName, []byte("testfile.txt")),
                                        NewField(FieldFilePath, []byte{0x00, 0x00}),
                                ),
                        },
                        wantRes: []Transaction{
                                {
-                                       clientID: &[]byte{0, 1},
+                                       clientID: [2]byte{0, 1},
                                        IsReply:  0x01,
                                        Type:     [2]byte{0, 0},
                                        Fields: []Field{
@@ -708,18 +732,13 @@ func TestHandleGetFileInfo(t *testing.T) {
                                        },
                                },
                        },
-                       wantErr: false,
                },
        }
        for _, tt := range tests {
                t.Run(tt.name, func(t *testing.T) {
-                       gotRes, err := HandleGetFileInfo(tt.args.cc, tt.args.t)
-                       if (err != nil) != tt.wantErr {
-                               t.Errorf("HandleGetFileInfo() error = %v, wantErr %v", err, tt.wantErr)
-                               return
-                       }
+                       gotRes := HandleGetFileInfo(tt.args.cc, &tt.args.t)
 
-                       // Clear the fileWrapper timestamp fields to work around problems running the tests in multiple timezones
+                       // Clear the file timestamp fields to work around problems running the tests in multiple timezones
                        // TODO: revisit how to test this by mocking the stat calls
                        gotRes[0].Fields[4].Data = make([]byte, 8)
                        gotRes[0].Fields[5].Data = make([]byte, 8)
@@ -734,13 +753,12 @@ func TestHandleGetFileInfo(t *testing.T) {
 func TestHandleNewFolder(t *testing.T) {
        type args struct {
                cc *ClientConn
-               t  *Transaction
+               t  Transaction
        }
        tests := []struct {
                name    string
                args    args
                wantRes []Transaction
-               wantErr bool
        }{
                {
                        name: "without required permission",
@@ -754,8 +772,8 @@ func TestHandleNewFolder(t *testing.T) {
                                        },
                                },
                                t: NewTransaction(
-                                       accessCreateFolder,
-                                       &[]byte{0, 0},
+                                       TranNewFolder,
+                                       [2]byte{0, 0},
                                ),
                        },
                        wantRes: []Transaction{
@@ -767,7 +785,6 @@ func TestHandleNewFolder(t *testing.T) {
                                        },
                                },
                        },
-                       wantErr: false,
                },
                {
                        name: "when path is nested",
@@ -776,13 +793,13 @@ func TestHandleNewFolder(t *testing.T) {
                                        Account: &Account{
                                                Access: func() accessBitmap {
                                                        var bits accessBitmap
-                                                       bits.Set(accessCreateFolder)
+                                                       bits.Set(AccessCreateFolder)
                                                        return bits
                                                }(),
                                        },
-                                       ID: &[]byte{0, 1},
+                                       ID: [2]byte{0, 1},
                                        Server: &Server{
-                                               Config: &Config{
+                                               Config: Config{
                                                        FileRoot: "/Files/",
                                                },
                                                FS: func() *MockFileStore {
@@ -794,7 +811,7 @@ func TestHandleNewFolder(t *testing.T) {
                                        },
                                },
                                t: NewTransaction(
-                                       TranNewFolder, &[]byte{0, 1},
+                                       TranNewFolder, [2]byte{0, 1},
                                        NewField(FieldFileName, []byte("testFolder")),
                                        NewField(FieldFilePath, []byte{
                                                0x00, 0x01,
@@ -806,11 +823,10 @@ func TestHandleNewFolder(t *testing.T) {
                        },
                        wantRes: []Transaction{
                                {
-                                       clientID: &[]byte{0, 1},
+                                       clientID: [2]byte{0, 1},
                                        IsReply:  0x01,
                                },
                        },
-                       wantErr: false,
                },
                {
                        name: "when path is not nested",
@@ -819,13 +835,13 @@ func TestHandleNewFolder(t *testing.T) {
                                        Account: &Account{
                                                Access: func() accessBitmap {
                                                        var bits accessBitmap
-                                                       bits.Set(accessCreateFolder)
+                                                       bits.Set(AccessCreateFolder)
                                                        return bits
                                                }(),
                                        },
-                                       ID: &[]byte{0, 1},
+                                       ID: [2]byte{0, 1},
                                        Server: &Server{
-                                               Config: &Config{
+                                               Config: Config{
                                                        FileRoot: "/Files",
                                                },
                                                FS: func() *MockFileStore {
@@ -837,17 +853,16 @@ func TestHandleNewFolder(t *testing.T) {
                                        },
                                },
                                t: NewTransaction(
-                                       TranNewFolder, &[]byte{0, 1},
+                                       TranNewFolder, [2]byte{0, 1},
                                        NewField(FieldFileName, []byte("testFolder")),
                                ),
                        },
                        wantRes: []Transaction{
                                {
-                                       clientID: &[]byte{0, 1},
+                                       clientID: [2]byte{0, 1},
                                        IsReply:  0x01,
                                },
                        },
-                       wantErr: false,
                },
                {
                        name: "when Write returns an err",
@@ -856,13 +871,13 @@ func TestHandleNewFolder(t *testing.T) {
                                        Account: &Account{
                                                Access: func() accessBitmap {
                                                        var bits accessBitmap
-                                                       bits.Set(accessCreateFolder)
+                                                       bits.Set(AccessCreateFolder)
                                                        return bits
                                                }(),
                                        },
-                                       ID: &[]byte{0, 1},
+                                       ID: [2]byte{0, 1},
                                        Server: &Server{
-                                               Config: &Config{
+                                               Config: Config{
                                                        FileRoot: "/Files/",
                                                },
                                                FS: func() *MockFileStore {
@@ -874,7 +889,7 @@ func TestHandleNewFolder(t *testing.T) {
                                        },
                                },
                                t: NewTransaction(
-                                       TranNewFolder, &[]byte{0, 1},
+                                       TranNewFolder, [2]byte{0, 1},
                                        NewField(FieldFileName, []byte("testFolder")),
                                        NewField(FieldFilePath, []byte{
                                                0x00,
@@ -882,7 +897,6 @@ func TestHandleNewFolder(t *testing.T) {
                                ),
                        },
                        wantRes: []Transaction{},
-                       wantErr: true,
                },
                {
                        name: "FieldFileName does not allow directory traversal",
@@ -891,13 +905,13 @@ func TestHandleNewFolder(t *testing.T) {
                                        Account: &Account{
                                                Access: func() accessBitmap {
                                                        var bits accessBitmap
-                                                       bits.Set(accessCreateFolder)
+                                                       bits.Set(AccessCreateFolder)
                                                        return bits
                                                }(),
                                        },
-                                       ID: &[]byte{0, 1},
+                                       ID: [2]byte{0, 1},
                                        Server: &Server{
-                                               Config: &Config{
+                                               Config: Config{
                                                        FileRoot: "/Files/",
                                                },
                                                FS: func() *MockFileStore {
@@ -909,16 +923,16 @@ func TestHandleNewFolder(t *testing.T) {
                                        },
                                },
                                t: NewTransaction(
-                                       TranNewFolder, &[]byte{0, 1},
+                                       TranNewFolder, [2]byte{0, 1},
                                        NewField(FieldFileName, []byte("../../testFolder")),
                                ),
                        },
                        wantRes: []Transaction{
                                {
-                                       clientID: &[]byte{0, 1},
+                                       clientID: [2]byte{0, 1},
                                        IsReply:  0x01,
                                },
-                       }, wantErr: false,
+                       },
                },
                {
                        name: "FieldFilePath does not allow directory traversal",
@@ -927,13 +941,13 @@ func TestHandleNewFolder(t *testing.T) {
                                        Account: &Account{
                                                Access: func() accessBitmap {
                                                        var bits accessBitmap
-                                                       bits.Set(accessCreateFolder)
+                                                       bits.Set(AccessCreateFolder)
                                                        return bits
                                                }(),
                                        },
-                                       ID: &[]byte{0, 1},
+                                       ID: [2]byte{0, 1},
                                        Server: &Server{
-                                               Config: &Config{
+                                               Config: Config{
                                                        FileRoot: "/Files/",
                                                },
                                                FS: func() *MockFileStore {
@@ -945,7 +959,7 @@ func TestHandleNewFolder(t *testing.T) {
                                        },
                                },
                                t: NewTransaction(
-                                       TranNewFolder, &[]byte{0, 1},
+                                       TranNewFolder, [2]byte{0, 1},
                                        NewField(FieldFileName, []byte("testFolder")),
                                        NewField(FieldFilePath, []byte{
                                                0x00, 0x02,
@@ -960,19 +974,15 @@ func TestHandleNewFolder(t *testing.T) {
                        },
                        wantRes: []Transaction{
                                {
-                                       clientID: &[]byte{0, 1},
+                                       clientID: [2]byte{0, 1},
                                        IsReply:  0x01,
                                },
-                       }, wantErr: false,
+                       },
                },
        }
        for _, tt := range tests {
                t.Run(tt.name, func(t *testing.T) {
-                       gotRes, err := HandleNewFolder(tt.args.cc, tt.args.t)
-                       if (err != nil) != tt.wantErr {
-                               t.Errorf("HandleNewFolder() error = %v, wantErr %v", err, tt.wantErr)
-                               return
-                       }
+                       gotRes := HandleNewFolder(tt.args.cc, &tt.args.t)
 
                        if !tranAssertEqual(t, tt.wantRes, gotRes) {
                                t.Errorf("HandleNewFolder() gotRes = %v, want %v", gotRes, tt.wantRes)
@@ -984,38 +994,35 @@ func TestHandleNewFolder(t *testing.T) {
 func TestHandleUploadFile(t *testing.T) {
        type args struct {
                cc *ClientConn
-               t  *Transaction
+               t  Transaction
        }
        tests := []struct {
                name    string
                args    args
                wantRes []Transaction
-               wantErr bool
        }{
                {
                        name: "when request is valid and user has Upload Anywhere permission",
                        args: args{
                                cc: &ClientConn{
                                        Server: &Server{
-                                               FS:            &OSFileStore{},
-                                               fileTransfers: map[[4]byte]*FileTransfer{},
-                                               Config: &Config{
+                                               FS:              &OSFileStore{},
+                                               FileTransferMgr: NewMemFileTransferMgr(),
+                                               Config: Config{
                                                        FileRoot: func() string { path, _ := os.Getwd(); return path + "/test/config/Files" }(),
                                                }},
-                                       transfers: map[int]map[[4]byte]*FileTransfer{
-                                               FileUpload: {},
-                                       },
+                                       ClientFileTransferMgr: NewClientFileTransferMgr(),
                                        Account: &Account{
                                                Access: func() accessBitmap {
                                                        var bits accessBitmap
-                                                       bits.Set(accessUploadFile)
-                                                       bits.Set(accessUploadAnywhere)
+                                                       bits.Set(AccessUploadFile)
+                                                       bits.Set(AccessUploadAnywhere)
                                                        return bits
                                                }(),
                                        },
                                },
                                t: NewTransaction(
-                                       TranUploadFile, &[]byte{0, 1},
+                                       TranUploadFile, [2]byte{0, 1},
                                        NewField(FieldFileName, []byte("testFile")),
                                        NewField(FieldFilePath, []byte{
                                                0x00, 0x01,
@@ -1033,7 +1040,6 @@ func TestHandleUploadFile(t *testing.T) {
                                        },
                                },
                        },
-                       wantErr: false,
                },
                {
                        name: "when user does not have required access",
@@ -1047,7 +1053,7 @@ func TestHandleUploadFile(t *testing.T) {
                                        },
                                },
                                t: NewTransaction(
-                                       TranUploadFile, &[]byte{0, 1},
+                                       TranUploadFile, [2]byte{0, 1},
                                        NewField(FieldFileName, []byte("testFile")),
                                        NewField(FieldFilePath, []byte{
                                                0x00, 0x01,
@@ -1066,17 +1072,11 @@ func TestHandleUploadFile(t *testing.T) {
                                        },
                                },
                        },
-                       wantErr: false,
                },
        }
        for _, tt := range tests {
                t.Run(tt.name, func(t *testing.T) {
-                       gotRes, err := HandleUploadFile(tt.args.cc, tt.args.t)
-                       if (err != nil) != tt.wantErr {
-                               t.Errorf("HandleUploadFile() error = %v, wantErr %v", err, tt.wantErr)
-                               return
-                       }
-
+                       gotRes := HandleUploadFile(tt.args.cc, &tt.args.t)
                        tranAssertEqual(t, tt.wantRes, gotRes)
                })
        }
@@ -1085,13 +1085,12 @@ func TestHandleUploadFile(t *testing.T) {
 func TestHandleMakeAlias(t *testing.T) {
        type args struct {
                cc *ClientConn
-               t  *Transaction
+               t  Transaction
        }
        tests := []struct {
                name    string
                args    args
                wantRes []Transaction
-               wantErr bool
        }{
                {
                        name: "with valid input and required permissions",
@@ -1101,12 +1100,12 @@ func TestHandleMakeAlias(t *testing.T) {
                                        Account: &Account{
                                                Access: func() accessBitmap {
                                                        var bits accessBitmap
-                                                       bits.Set(accessMakeAlias)
+                                                       bits.Set(AccessMakeAlias)
                                                        return bits
                                                }(),
                                        },
                                        Server: &Server{
-                                               Config: &Config{
+                                               Config: Config{
                                                        FileRoot: func() string {
                                                                path, _ := os.Getwd()
                                                                return path + "/test/config/Files"
@@ -1126,7 +1125,7 @@ func TestHandleMakeAlias(t *testing.T) {
                                        },
                                },
                                t: NewTransaction(
-                                       TranMakeFileAlias, &[]byte{0, 1},
+                                       TranMakeFileAlias, [2]byte{0, 1},
                                        NewField(FieldFileName, []byte("testFile")),
                                        NewField(FieldFilePath, EncodeFilePath(strings.Join([]string{"foo"}, "/"))),
                                        NewField(FieldFileNewPath, EncodeFilePath(strings.Join([]string{"bar"}, "/"))),
@@ -1138,7 +1137,6 @@ func TestHandleMakeAlias(t *testing.T) {
                                        Fields:  []Field(nil),
                                },
                        },
-                       wantErr: false,
                },
                {
                        name: "when symlink returns an error",
@@ -1148,12 +1146,12 @@ func TestHandleMakeAlias(t *testing.T) {
                                        Account: &Account{
                                                Access: func() accessBitmap {
                                                        var bits accessBitmap
-                                                       bits.Set(accessMakeAlias)
+                                                       bits.Set(AccessMakeAlias)
                                                        return bits
                                                }(),
                                        },
                                        Server: &Server{
-                                               Config: &Config{
+                                               Config: Config{
                                                        FileRoot: func() string {
                                                                path, _ := os.Getwd()
                                                                return path + "/test/config/Files"
@@ -1173,7 +1171,7 @@ func TestHandleMakeAlias(t *testing.T) {
                                        },
                                },
                                t: NewTransaction(
-                                       TranMakeFileAlias, &[]byte{0, 1},
+                                       TranMakeFileAlias, [2]byte{0, 1},
                                        NewField(FieldFileName, []byte("testFile")),
                                        NewField(FieldFilePath, EncodeFilePath(strings.Join([]string{"foo"}, "/"))),
                                        NewField(FieldFileNewPath, EncodeFilePath(strings.Join([]string{"bar"}, "/"))),
@@ -1188,7 +1186,6 @@ func TestHandleMakeAlias(t *testing.T) {
                                        },
                                },
                        },
-                       wantErr: false,
                },
                {
                        name: "when user does not have required permission",
@@ -1196,13 +1193,10 @@ func TestHandleMakeAlias(t *testing.T) {
                                cc: &ClientConn{
                                        logger: NewTestLogger(),
                                        Account: &Account{
-                                               Access: func() accessBitmap {
-                                                       var bits accessBitmap
-                                                       return bits
-                                               }(),
+                                               Access: accessBitmap{},
                                        },
                                        Server: &Server{
-                                               Config: &Config{
+                                               Config: Config{
                                                        FileRoot: func() string {
                                                                path, _ := os.Getwd()
                                                                return path + "/test/config/Files"
@@ -1211,7 +1205,7 @@ func TestHandleMakeAlias(t *testing.T) {
                                        },
                                },
                                t: NewTransaction(
-                                       TranMakeFileAlias, &[]byte{0, 1},
+                                       TranMakeFileAlias, [2]byte{0, 1},
                                        NewField(FieldFileName, []byte("testFile")),
                                        NewField(FieldFilePath, []byte{
                                                0x00, 0x01,
@@ -1236,17 +1230,11 @@ func TestHandleMakeAlias(t *testing.T) {
                                        },
                                },
                        },
-                       wantErr: false,
                },
        }
        for _, tt := range tests {
                t.Run(tt.name, func(t *testing.T) {
-                       gotRes, err := HandleMakeAlias(tt.args.cc, tt.args.t)
-                       if (err != nil) != tt.wantErr {
-                               t.Errorf("HandleMakeAlias(%v, %v)", tt.args.cc, tt.args.t)
-                               return
-                       }
-
+                       gotRes := HandleMakeAlias(tt.args.cc, &tt.args.t)
                        tranAssertEqual(t, tt.wantRes, gotRes)
                })
        }
@@ -1255,13 +1243,12 @@ func TestHandleMakeAlias(t *testing.T) {
 func TestHandleGetUser(t *testing.T) {
        type args struct {
                cc *ClientConn
-               t  *Transaction
+               t  Transaction
        }
        tests := []struct {
                name    string
                args    args
                wantRes []Transaction
-               wantErr assert.ErrorAssertionFunc
        }{
                {
                        name: "when account is valid",
@@ -1270,23 +1257,25 @@ func TestHandleGetUser(t *testing.T) {
                                        Account: &Account{
                                                Access: func() accessBitmap {
                                                        var bits accessBitmap
-                                                       bits.Set(accessOpenUser)
+                                                       bits.Set(AccessOpenUser)
                                                        return bits
                                                }(),
                                        },
                                        Server: &Server{
-                                               Accounts: map[string]*Account{
-                                                       "guest": {
+                                               AccountManager: func() *MockAccountManager {
+                                                       m := MockAccountManager{}
+                                                       m.On("Get", "guest").Return(&Account{
                                                                Login:    "guest",
                                                                Name:     "Guest",
                                                                Password: "password",
                                                                Access:   accessBitmap{},
-                                                       },
-                                               },
+                                                       })
+                                                       return &m
+                                               }(),
                                        },
                                },
                                t: NewTransaction(
-                                       TranGetUser, &[]byte{0, 1},
+                                       TranGetUser, [2]byte{0, 1},
                                        NewField(FieldUserLogin, []byte("guest")),
                                ),
                        },
@@ -1301,7 +1290,6 @@ func TestHandleGetUser(t *testing.T) {
                                        },
                                },
                        },
-                       wantErr: assert.NoError,
                },
                {
                        name: "when user does not have required permission",
@@ -1314,11 +1302,11 @@ func TestHandleGetUser(t *testing.T) {
                                                }(),
                                        },
                                        Server: &Server{
-                                               Accounts: map[string]*Account{},
+                                               //Accounts: map[string]*Account{},
                                        },
                                },
                                t: NewTransaction(
-                                       TranGetUser, &[]byte{0, 1},
+                                       TranGetUser, [2]byte{0, 1},
                                        NewField(FieldUserLogin, []byte("nonExistentUser")),
                                ),
                        },
@@ -1331,7 +1319,6 @@ func TestHandleGetUser(t *testing.T) {
                                        },
                                },
                        },
-                       wantErr: assert.NoError,
                },
                {
                        name: "when account does not exist",
@@ -1340,16 +1327,20 @@ func TestHandleGetUser(t *testing.T) {
                                        Account: &Account{
                                                Access: func() accessBitmap {
                                                        var bits accessBitmap
-                                                       bits.Set(accessOpenUser)
+                                                       bits.Set(AccessOpenUser)
                                                        return bits
                                                }(),
                                        },
                                        Server: &Server{
-                                               Accounts: map[string]*Account{},
+                                               AccountManager: func() *MockAccountManager {
+                                                       m := MockAccountManager{}
+                                                       m.On("Get", "nonExistentUser").Return((*Account)(nil))
+                                                       return &m
+                                               }(),
                                        },
                                },
                                t: NewTransaction(
-                                       TranGetUser, &[]byte{0, 1},
+                                       TranGetUser, [2]byte{0, 1},
                                        NewField(FieldUserLogin, []byte("nonExistentUser")),
                                ),
                        },
@@ -1364,16 +1355,11 @@ func TestHandleGetUser(t *testing.T) {
                                        },
                                },
                        },
-                       wantErr: assert.NoError,
                },
        }
        for _, tt := range tests {
                t.Run(tt.name, func(t *testing.T) {
-                       gotRes, err := HandleGetUser(tt.args.cc, tt.args.t)
-                       if !tt.wantErr(t, err, fmt.Sprintf("HandleGetUser(%v, %v)", tt.args.cc, tt.args.t)) {
-                               return
-                       }
-
+                       gotRes := HandleGetUser(tt.args.cc, &tt.args.t)
                        tranAssertEqual(t, tt.wantRes, gotRes)
                })
        }
@@ -1382,43 +1368,39 @@ func TestHandleGetUser(t *testing.T) {
 func TestHandleDeleteUser(t *testing.T) {
        type args struct {
                cc *ClientConn
-               t  *Transaction
+               t  Transaction
        }
        tests := []struct {
                name    string
                args    args
                wantRes []Transaction
-               wantErr assert.ErrorAssertionFunc
        }{
                {
-                       name: "when user dataFile",
+                       name: "when user exists",
                        args: args{
                                cc: &ClientConn{
                                        Account: &Account{
                                                Access: func() accessBitmap {
                                                        var bits accessBitmap
-                                                       bits.Set(accessDeleteUser)
+                                                       bits.Set(AccessDeleteUser)
                                                        return bits
                                                }(),
                                        },
                                        Server: &Server{
-                                               Accounts: map[string]*Account{
-                                                       "testuser": {
-                                                               Login:    "testuser",
-                                                               Name:     "Testy McTest",
-                                                               Password: "password",
-                                                               Access:   accessBitmap{},
-                                                       },
-                                               },
-                                               FS: func() *MockFileStore {
-                                                       mfs := &MockFileStore{}
-                                                       mfs.On("Remove", "Users/testuser.yaml").Return(nil)
-                                                       return mfs
+                                               AccountManager: func() *MockAccountManager {
+                                                       m := MockAccountManager{}
+                                                       m.On("Delete", "testuser").Return(nil)
+                                                       return &m
+                                               }(),
+                                               ClientMgr: func() *MockClientMgr {
+                                                       m := MockClientMgr{}
+                                                       m.On("List").Return([]*ClientConn{}) // TODO
+                                                       return &m
                                                }(),
                                        },
                                },
                                t: NewTransaction(
-                                       TranDeleteUser, &[]byte{0, 1},
+                                       TranDeleteUser, [2]byte{0, 1},
                                        NewField(FieldUserLogin, encodeString([]byte("testuser"))),
                                ),
                        },
@@ -1430,24 +1412,20 @@ func TestHandleDeleteUser(t *testing.T) {
                                        Fields:  []Field(nil),
                                },
                        },
-                       wantErr: assert.NoError,
                },
                {
                        name: "when user does not have required permission",
                        args: args{
                                cc: &ClientConn{
                                        Account: &Account{
-                                               Access: func() accessBitmap {
-                                                       var bits accessBitmap
-                                                       return bits
-                                               }(),
+                                               Access: accessBitmap{},
                                        },
                                        Server: &Server{
-                                               Accounts: map[string]*Account{},
+                                               //Accounts: map[string]*Account{},
                                        },
                                },
                                t: NewTransaction(
-                                       TranDeleteUser, &[]byte{0, 1},
+                                       TranDeleteUser, [2]byte{0, 1},
                                        NewField(FieldUserLogin, encodeString([]byte("testuser"))),
                                ),
                        },
@@ -1460,16 +1438,11 @@ func TestHandleDeleteUser(t *testing.T) {
                                        },
                                },
                        },
-                       wantErr: assert.NoError,
                },
        }
        for _, tt := range tests {
                t.Run(tt.name, func(t *testing.T) {
-                       gotRes, err := HandleDeleteUser(tt.args.cc, tt.args.t)
-                       if !tt.wantErr(t, err, fmt.Sprintf("HandleDeleteUser(%v, %v)", tt.args.cc, tt.args.t)) {
-                               return
-                       }
-
+                       gotRes := HandleDeleteUser(tt.args.cc, &tt.args.t)
                        tranAssertEqual(t, tt.wantRes, gotRes)
                })
        }
@@ -1478,13 +1451,12 @@ func TestHandleDeleteUser(t *testing.T) {
 func TestHandleGetMsgs(t *testing.T) {
        type args struct {
                cc *ClientConn
-               t  *Transaction
+               t  Transaction
        }
        tests := []struct {
                name    string
                args    args
                wantRes []Transaction
-               wantErr assert.ErrorAssertionFunc
        }{
                {
                        name: "returns news data",
@@ -1493,16 +1465,24 @@ func TestHandleGetMsgs(t *testing.T) {
                                        Account: &Account{
                                                Access: func() accessBitmap {
                                                        var bits accessBitmap
-                                                       bits.Set(accessNewsReadArt)
+                                                       bits.Set(AccessNewsReadArt)
                                                        return bits
                                                }(),
                                        },
                                        Server: &Server{
-                                               FlatNews: []byte("TEST"),
+                                               MessageBoard: func() *mockReadWriteSeeker {
+                                                       m := mockReadWriteSeeker{}
+                                                       m.On("Seek", int64(0), 0).Return(int64(0), nil)
+                                                       m.On("Read", mock.AnythingOfType("[]uint8")).Run(func(args mock.Arguments) {
+                                                               arg := args.Get(0).([]uint8)
+                                                               copy(arg, "TEST")
+                                                       }).Return(4, io.EOF)
+                                                       return &m
+                                               }(),
                                        },
                                },
                                t: NewTransaction(
-                                       TranGetMsgs, &[]byte{0, 1},
+                                       TranGetMsgs, [2]byte{0, 1},
                                ),
                        },
                        wantRes: []Transaction{
@@ -1513,24 +1493,20 @@ func TestHandleGetMsgs(t *testing.T) {
                                        },
                                },
                        },
-                       wantErr: assert.NoError,
                },
                {
                        name: "when user does not have required permission",
                        args: args{
                                cc: &ClientConn{
                                        Account: &Account{
-                                               Access: func() accessBitmap {
-                                                       var bits accessBitmap
-                                                       return bits
-                                               }(),
+                                               Access: accessBitmap{},
                                        },
                                        Server: &Server{
-                                               Accounts: map[string]*Account{},
+                                               //Accounts: map[string]*Account{},
                                        },
                                },
                                t: NewTransaction(
-                                       TranGetMsgs, &[]byte{0, 1},
+                                       TranGetMsgs, [2]byte{0, 1},
                                ),
                        },
                        wantRes: []Transaction{
@@ -1542,16 +1518,11 @@ func TestHandleGetMsgs(t *testing.T) {
                                        },
                                },
                        },
-                       wantErr: assert.NoError,
                },
        }
        for _, tt := range tests {
                t.Run(tt.name, func(t *testing.T) {
-                       gotRes, err := HandleGetMsgs(tt.args.cc, tt.args.t)
-                       if !tt.wantErr(t, err, fmt.Sprintf("HandleGetMsgs(%v, %v)", tt.args.cc, tt.args.t)) {
-                               return
-                       }
-
+                       gotRes := HandleGetMsgs(tt.args.cc, &tt.args.t)
                        tranAssertEqual(t, tt.wantRes, gotRes)
                })
        }
@@ -1560,13 +1531,12 @@ func TestHandleGetMsgs(t *testing.T) {
 func TestHandleNewUser(t *testing.T) {
        type args struct {
                cc *ClientConn
-               t  *Transaction
+               t  Transaction
        }
        tests := []struct {
                name    string
                args    args
                wantRes []Transaction
-               wantErr assert.ErrorAssertionFunc
        }{
                {
                        name: "when user does not have required permission",
@@ -1579,11 +1549,11 @@ func TestHandleNewUser(t *testing.T) {
                                                }(),
                                        },
                                        Server: &Server{
-                                               Accounts: map[string]*Account{},
+                                               //Accounts: map[string]*Account{},
                                        },
                                },
                                t: NewTransaction(
-                                       TranNewUser, &[]byte{0, 1},
+                                       TranNewUser, [2]byte{0, 1},
                                ),
                        },
                        wantRes: []Transaction{
@@ -1595,7 +1565,6 @@ func TestHandleNewUser(t *testing.T) {
                                        },
                                },
                        },
-                       wantErr: assert.NoError,
                },
                {
                        name: "when user attempts to create account with greater access",
@@ -1604,22 +1573,26 @@ func TestHandleNewUser(t *testing.T) {
                                        Account: &Account{
                                                Access: func() accessBitmap {
                                                        var bits accessBitmap
-                                                       bits.Set(accessCreateUser)
+                                                       bits.Set(AccessCreateUser)
                                                        return bits
                                                }(),
                                        },
                                        Server: &Server{
-                                               Accounts: map[string]*Account{},
+                                               AccountManager: func() *MockAccountManager {
+                                                       m := MockAccountManager{}
+                                                       m.On("Get", "userB").Return((*Account)(nil))
+                                                       return &m
+                                               }(),
                                        },
                                },
                                t: NewTransaction(
-                                       TranNewUser, &[]byte{0, 1},
-                                       NewField(FieldUserLogin, []byte("userB")),
+                                       TranNewUser, [2]byte{0, 1},
+                                       NewField(FieldUserLogin, encodeString([]byte("userB"))),
                                        NewField(
                                                FieldUserAccess,
                                                func() []byte {
                                                        var bits accessBitmap
-                                                       bits.Set(accessDisconUser)
+                                                       bits.Set(AccessDisconUser)
                                                        return bits[:]
                                                }(),
                                        ),
@@ -1634,16 +1607,11 @@ func TestHandleNewUser(t *testing.T) {
                                        },
                                },
                        },
-                       wantErr: assert.NoError,
                },
        }
        for _, tt := range tests {
                t.Run(tt.name, func(t *testing.T) {
-                       gotRes, err := HandleNewUser(tt.args.cc, tt.args.t)
-                       if !tt.wantErr(t, err, fmt.Sprintf("HandleNewUser(%v, %v)", tt.args.cc, tt.args.t)) {
-                               return
-                       }
-
+                       gotRes := HandleNewUser(tt.args.cc, &tt.args.t)
                        tranAssertEqual(t, tt.wantRes, gotRes)
                })
        }
@@ -1652,13 +1620,12 @@ func TestHandleNewUser(t *testing.T) {
 func TestHandleListUsers(t *testing.T) {
        type args struct {
                cc *ClientConn
-               t  *Transaction
+               t  Transaction
        }
        tests := []struct {
                name    string
                args    args
                wantRes []Transaction
-               wantErr assert.ErrorAssertionFunc
        }{
                {
                        name: "when user does not have required permission",
@@ -1671,11 +1638,11 @@ func TestHandleListUsers(t *testing.T) {
                                                }(),
                                        },
                                        Server: &Server{
-                                               Accounts: map[string]*Account{},
+                                               //Accounts: map[string]*Account{},
                                        },
                                },
                                t: NewTransaction(
-                                       TranNewUser, &[]byte{0, 1},
+                                       TranNewUser, [2]byte{0, 1},
                                ),
                        },
                        wantRes: []Transaction{
@@ -1687,7 +1654,6 @@ func TestHandleListUsers(t *testing.T) {
                                        },
                                },
                        },
-                       wantErr: assert.NoError,
                },
                {
                        name: "when user has required permission",
@@ -1696,23 +1662,27 @@ func TestHandleListUsers(t *testing.T) {
                                        Account: &Account{
                                                Access: func() accessBitmap {
                                                        var bits accessBitmap
-                                                       bits.Set(accessOpenUser)
+                                                       bits.Set(AccessOpenUser)
                                                        return bits
                                                }(),
                                        },
                                        Server: &Server{
-                                               Accounts: map[string]*Account{
-                                                       "guest": {
-                                                               Name:     "guest",
-                                                               Login:    "guest",
-                                                               Password: "zz",
-                                                               Access:   accessBitmap{255, 255, 255, 255, 255, 255, 255, 255},
-                                                       },
-                                               },
+                                               AccountManager: func() *MockAccountManager {
+                                                       m := MockAccountManager{}
+                                                       m.On("List").Return([]Account{
+                                                               {
+                                                                       Name:     "guest",
+                                                                       Login:    "guest",
+                                                                       Password: "zz",
+                                                                       Access:   accessBitmap{255, 255, 255, 255, 255, 255, 255, 255},
+                                                               },
+                                                       })
+                                                       return &m
+                                               }(),
                                        },
                                },
                                t: NewTransaction(
-                                       TranGetClientInfoText, &[]byte{0, 1},
+                                       TranGetClientInfoText, [2]byte{0, 1},
                                        NewField(FieldUserID, []byte{0, 1}),
                                ),
                        },
@@ -1728,15 +1698,11 @@ func TestHandleListUsers(t *testing.T) {
                                        },
                                },
                        },
-                       wantErr: assert.NoError,
                },
        }
        for _, tt := range tests {
                t.Run(tt.name, func(t *testing.T) {
-                       gotRes, err := HandleListUsers(tt.args.cc, tt.args.t)
-                       if !tt.wantErr(t, err, fmt.Sprintf("HandleListUsers(%v, %v)", tt.args.cc, tt.args.t)) {
-                               return
-                       }
+                       gotRes := HandleListUsers(tt.args.cc, &tt.args.t)
 
                        tranAssertEqual(t, tt.wantRes, gotRes)
                })
@@ -1746,13 +1712,12 @@ func TestHandleListUsers(t *testing.T) {
 func TestHandleDownloadFile(t *testing.T) {
        type args struct {
                cc *ClientConn
-               t  *Transaction
+               t  Transaction
        }
        tests := []struct {
                name    string
                args    args
                wantRes []Transaction
-               wantErr assert.ErrorAssertionFunc
        }{
                {
                        name: "when user does not have required permission",
@@ -1766,7 +1731,7 @@ func TestHandleDownloadFile(t *testing.T) {
                                        },
                                        Server: &Server{},
                                },
-                               t: NewTransaction(TranDownloadFile, &[]byte{0, 1}),
+                               t: NewTransaction(TranDownloadFile, [2]byte{0, 1}),
                        },
                        wantRes: []Transaction{
                                {
@@ -1777,34 +1742,30 @@ func TestHandleDownloadFile(t *testing.T) {
                                        },
                                },
                        },
-                       wantErr: assert.NoError,
                },
                {
                        name: "with a valid file",
                        args: args{
                                cc: &ClientConn{
-                                       transfers: map[int]map[[4]byte]*FileTransfer{
-                                               FileDownload: {},
-                                       },
+                                       ClientFileTransferMgr: NewClientFileTransferMgr(),
                                        Account: &Account{
                                                Access: func() accessBitmap {
                                                        var bits accessBitmap
-                                                       bits.Set(accessDownloadFile)
+                                                       bits.Set(AccessDownloadFile)
                                                        return bits
                                                }(),
                                        },
                                        Server: &Server{
-                                               FS:            &OSFileStore{},
-                                               fileTransfers: map[[4]byte]*FileTransfer{},
-                                               Config: &Config{
+                                               FS:              &OSFileStore{},
+                                               FileTransferMgr: NewMemFileTransferMgr(),
+                                               Config: Config{
                                                        FileRoot: func() string { path, _ := os.Getwd(); return path + "/test/config/Files" }(),
                                                },
-                                               Accounts: map[string]*Account{},
                                        },
                                },
                                t: NewTransaction(
-                                       accessDownloadFile,
-                                       &[]byte{0, 1},
+                                       TranDownloadFile,
+                                       [2]byte{0, 1},
                                        NewField(FieldFileName, []byte("testfile.txt")),
                                        NewField(FieldFilePath, []byte{0x0, 0x00}),
                                ),
@@ -1820,18 +1781,16 @@ func TestHandleDownloadFile(t *testing.T) {
                                        },
                                },
                        },
-                       wantErr: assert.NoError,
                },
                {
                        name: "when client requests to resume 1k test file at offset 256",
                        args: args{
                                cc: &ClientConn{
-                                       transfers: map[int]map[[4]byte]*FileTransfer{
-                                               FileDownload: {},
-                                       }, Account: &Account{
+                                       ClientFileTransferMgr: NewClientFileTransferMgr(),
+                                       Account: &Account{
                                                Access: func() accessBitmap {
                                                        var bits accessBitmap
-                                                       bits.Set(accessDownloadFile)
+                                                       bits.Set(AccessDownloadFile)
                                                        return bits
                                                }(),
                                        },
@@ -1855,38 +1814,31 @@ func TestHandleDownloadFile(t *testing.T) {
                                                //
                                                //      return mfs
                                                // }(),
-                                               fileTransfers: map[[4]byte]*FileTransfer{},
-                                               Config: &Config{
+                                               FileTransferMgr: NewMemFileTransferMgr(),
+                                               Config: Config{
                                                        FileRoot: func() string { path, _ := os.Getwd(); return path + "/test/config/Files" }(),
                                                },
-                                               Accounts: map[string]*Account{},
+                                               //Accounts: map[string]*Account{},
                                        },
                                },
                                t: NewTransaction(
-                                       accessDownloadFile,
-                                       &[]byte{0, 1},
+                                       TranDownloadFile,
+                                       [2]byte{0, 1},
                                        NewField(FieldFileName, []byte("testfile-1k")),
                                        NewField(FieldFilePath, []byte{0x00, 0x00}),
                                        NewField(
                                                FieldFileResumeData,
                                                func() []byte {
                                                        frd := FileResumeData{
-                                                               Format:    [4]byte{},
-                                                               Version:   [2]byte{},
-                                                               RSVD:      [34]byte{},
                                                                ForkCount: [2]byte{0, 2},
                                                                ForkInfoList: []ForkInfoList{
                                                                        {
                                                                                Fork:     [4]byte{0x44, 0x41, 0x54, 0x41}, // "DATA"
                                                                                DataSize: [4]byte{0, 0, 0x01, 0x00},       // request offset 256
-                                                                               RSVDA:    [4]byte{},
-                                                                               RSVDB:    [4]byte{},
                                                                        },
                                                                        {
                                                                                Fork:     [4]byte{0x4d, 0x41, 0x43, 0x52}, // "MACR"
                                                                                DataSize: [4]byte{0, 0, 0, 0},
-                                                                               RSVDA:    [4]byte{},
-                                                                               RSVDB:    [4]byte{},
                                                                        },
                                                                },
                                                        }
@@ -1907,16 +1859,11 @@ func TestHandleDownloadFile(t *testing.T) {
                                        },
                                },
                        },
-                       wantErr: assert.NoError,
                },
        }
        for _, tt := range tests {
                t.Run(tt.name, func(t *testing.T) {
-                       gotRes, err := HandleDownloadFile(tt.args.cc, tt.args.t)
-                       if !tt.wantErr(t, err, fmt.Sprintf("HandleDownloadFile(%v, %v)", tt.args.cc, tt.args.t)) {
-                               return
-                       }
-
+                       gotRes := HandleDownloadFile(tt.args.cc, &tt.args.t)
                        tranAssertEqual(t, tt.wantRes, gotRes)
                })
        }
@@ -1925,13 +1872,12 @@ func TestHandleDownloadFile(t *testing.T) {
 func TestHandleUpdateUser(t *testing.T) {
        type args struct {
                cc *ClientConn
-               t  *Transaction
+               t  Transaction
        }
        tests := []struct {
                name    string
                args    args
                wantRes []Transaction
-               wantErr assert.ErrorAssertionFunc
        }{
                {
                        name: "when action is create user without required permission",
@@ -1939,18 +1885,20 @@ func TestHandleUpdateUser(t *testing.T) {
                                cc: &ClientConn{
                                        logger: NewTestLogger(),
                                        Server: &Server{
+                                               AccountManager: func() *MockAccountManager {
+                                                       m := MockAccountManager{}
+                                                       m.On("Get", "bbb").Return((*Account)(nil))
+                                                       return &m
+                                               }(),
                                                Logger: NewTestLogger(),
                                        },
                                        Account: &Account{
-                                               Access: func() accessBitmap {
-                                                       var bits accessBitmap
-                                                       return bits
-                                               }(),
+                                               Access: accessBitmap{},
                                        },
                                },
                                t: NewTransaction(
                                        TranUpdateUser,
-                                       &[]byte{0, 0},
+                                       [2]byte{0, 0},
                                        NewField(FieldData, []byte{
                                                0x00, 0x04, // field count
 
@@ -1981,7 +1929,6 @@ func TestHandleUpdateUser(t *testing.T) {
                                        },
                                },
                        },
-                       wantErr: assert.NoError,
                },
                {
                        name: "when action is modify user without required permission",
@@ -1990,9 +1937,11 @@ func TestHandleUpdateUser(t *testing.T) {
                                        logger: NewTestLogger(),
                                        Server: &Server{
                                                Logger: NewTestLogger(),
-                                               Accounts: map[string]*Account{
-                                                       "bbb": {},
-                                               },
+                                               AccountManager: func() *MockAccountManager {
+                                                       m := MockAccountManager{}
+                                                       m.On("Get", "bbb").Return(&Account{})
+                                                       return &m
+                                               }(),
                                        },
                                        Account: &Account{
                                                Access: func() accessBitmap {
@@ -2003,7 +1952,7 @@ func TestHandleUpdateUser(t *testing.T) {
                                },
                                t: NewTransaction(
                                        TranUpdateUser,
-                                       &[]byte{0, 0},
+                                       [2]byte{0, 0},
                                        NewField(FieldData, []byte{
                                                0x00, 0x04, // field count
 
@@ -2034,28 +1983,20 @@ func TestHandleUpdateUser(t *testing.T) {
                                        },
                                },
                        },
-                       wantErr: assert.NoError,
                },
                {
                        name: "when action is delete user without required permission",
                        args: args{
                                cc: &ClientConn{
                                        logger: NewTestLogger(),
-                                       Server: &Server{
-                                               Accounts: map[string]*Account{
-                                                       "bbb": {},
-                                               },
-                                       },
+                                       Server: &Server{},
                                        Account: &Account{
-                                               Access: func() accessBitmap {
-                                                       var bits accessBitmap
-                                                       return bits
-                                               }(),
+                                               Access: accessBitmap{},
                                        },
                                },
                                t: NewTransaction(
                                        TranUpdateUser,
-                                       &[]byte{0, 0},
+                                       [2]byte{0, 0},
                                        NewField(FieldData, []byte{
                                                0x00, 0x01,
                                                0x00, 0x65,
@@ -2073,16 +2014,11 @@ func TestHandleUpdateUser(t *testing.T) {
                                        },
                                },
                        },
-                       wantErr: assert.NoError,
                },
        }
        for _, tt := range tests {
                t.Run(tt.name, func(t *testing.T) {
-                       gotRes, err := HandleUpdateUser(tt.args.cc, tt.args.t)
-                       if !tt.wantErr(t, err, fmt.Sprintf("HandleUpdateUser(%v, %v)", tt.args.cc, tt.args.t)) {
-                               return
-                       }
-
+                       gotRes := HandleUpdateUser(tt.args.cc, &tt.args.t)
                        tranAssertEqual(t, tt.wantRes, gotRes)
                })
        }
@@ -2091,13 +2027,12 @@ func TestHandleUpdateUser(t *testing.T) {
 func TestHandleDelNewsArt(t *testing.T) {
        type args struct {
                cc *ClientConn
-               t  *Transaction
+               t  Transaction
        }
        tests := []struct {
                name    string
                args    args
                wantRes []Transaction
-               wantErr assert.ErrorAssertionFunc
        }{
                {
                        name: "without required permission",
@@ -2112,7 +2047,7 @@ func TestHandleDelNewsArt(t *testing.T) {
                                },
                                t: NewTransaction(
                                        TranDelNewsArt,
-                                       &[]byte{0, 0},
+                                       [2]byte{0, 0},
                                ),
                        },
                        wantRes: []Transaction{
@@ -2124,15 +2059,11 @@ func TestHandleDelNewsArt(t *testing.T) {
                                        },
                                },
                        },
-                       wantErr: assert.NoError,
                },
        }
        for _, tt := range tests {
                t.Run(tt.name, func(t *testing.T) {
-                       gotRes, err := HandleDelNewsArt(tt.args.cc, tt.args.t)
-                       if !tt.wantErr(t, err, fmt.Sprintf("HandleDelNewsArt(%v, %v)", tt.args.cc, tt.args.t)) {
-                               return
-                       }
+                       gotRes := HandleDelNewsArt(tt.args.cc, &tt.args.t)
                        tranAssertEqual(t, tt.wantRes, gotRes)
                })
        }
@@ -2141,13 +2072,12 @@ func TestHandleDelNewsArt(t *testing.T) {
 func TestHandleDisconnectUser(t *testing.T) {
        type args struct {
                cc *ClientConn
-               t  *Transaction
+               t  Transaction
        }
        tests := []struct {
                name    string
                args    args
                wantRes []Transaction
-               wantErr assert.ErrorAssertionFunc
        }{
                {
                        name: "without required permission",
@@ -2162,7 +2092,7 @@ func TestHandleDisconnectUser(t *testing.T) {
                                },
                                t: NewTransaction(
                                        TranDelNewsArt,
-                                       &[]byte{0, 0},
+                                       [2]byte{0, 0},
                                ),
                        },
                        wantRes: []Transaction{
@@ -2174,37 +2104,39 @@ func TestHandleDisconnectUser(t *testing.T) {
                                        },
                                },
                        },
-                       wantErr: assert.NoError,
                },
                {
                        name: "when target user has 'cannot be disconnected' priv",
                        args: args{
                                cc: &ClientConn{
                                        Server: &Server{
-                                               Clients: map[uint16]*ClientConn{
-                                                       uint16(1): {
+                                               ClientMgr: func() *MockClientMgr {
+                                                       m := MockClientMgr{}
+                                                       m.On("Get", ClientID{0x0, 0x1}).Return(&ClientConn{
                                                                Account: &Account{
                                                                        Login: "unnamed",
                                                                        Access: func() accessBitmap {
                                                                                var bits accessBitmap
-                                                                               bits.Set(accessCannotBeDiscon)
+                                                                               bits.Set(AccessCannotBeDiscon)
                                                                                return bits
                                                                        }(),
                                                                },
                                                        },
-                                               },
+                                                       )
+                                                       return &m
+                                               }(),
                                        },
                                        Account: &Account{
                                                Access: func() accessBitmap {
                                                        var bits accessBitmap
-                                                       bits.Set(accessDisconUser)
+                                                       bits.Set(AccessDisconUser)
                                                        return bits
                                                }(),
                                        },
                                },
                                t: NewTransaction(
                                        TranDelNewsArt,
-                                       &[]byte{0, 0},
+                                       [2]byte{0, 0},
                                        NewField(FieldUserID, []byte{0, 1}),
                                ),
                        },
@@ -2217,15 +2149,11 @@ func TestHandleDisconnectUser(t *testing.T) {
                                        },
                                },
                        },
-                       wantErr: assert.NoError,
                },
        }
        for _, tt := range tests {
                t.Run(tt.name, func(t *testing.T) {
-                       gotRes, err := HandleDisconnectUser(tt.args.cc, tt.args.t)
-                       if !tt.wantErr(t, err, fmt.Sprintf("HandleDisconnectUser(%v, %v)", tt.args.cc, tt.args.t)) {
-                               return
-                       }
+                       gotRes := HandleDisconnectUser(tt.args.cc, &tt.args.t)
                        tranAssertEqual(t, tt.wantRes, gotRes)
                })
        }
@@ -2234,13 +2162,12 @@ func TestHandleDisconnectUser(t *testing.T) {
 func TestHandleSendInstantMsg(t *testing.T) {
        type args struct {
                cc *ClientConn
-               t  *Transaction
+               t  Transaction
        }
        tests := []struct {
                name    string
                args    args
                wantRes []Transaction
-               wantErr assert.ErrorAssertionFunc
        }{
                {
                        name: "without required permission",
@@ -2255,7 +2182,7 @@ func TestHandleSendInstantMsg(t *testing.T) {
                                },
                                t: NewTransaction(
                                        TranDelNewsArt,
-                                       &[]byte{0, 0},
+                                       [2]byte{0, 0},
                                ),
                        },
                        wantRes: []Transaction{
@@ -2267,7 +2194,6 @@ func TestHandleSendInstantMsg(t *testing.T) {
                                        },
                                },
                        },
-                       wantErr: assert.Error,
                },
                {
                        name: "when client 1 sends a message to client 2",
@@ -2276,44 +2202,46 @@ func TestHandleSendInstantMsg(t *testing.T) {
                                        Account: &Account{
                                                Access: func() accessBitmap {
                                                        var bits accessBitmap
-                                                       bits.Set(accessSendPrivMsg)
+                                                       bits.Set(AccessSendPrivMsg)
                                                        return bits
                                                }(),
                                        },
-                                       ID:       &[]byte{0, 1},
+                                       ID:       [2]byte{0, 1},
                                        UserName: []byte("User1"),
                                        Server: &Server{
-                                               Clients: map[uint16]*ClientConn{
-                                                       uint16(2): {
+                                               ClientMgr: func() *MockClientMgr {
+                                                       m := MockClientMgr{}
+                                                       m.On("Get", ClientID{0x0, 0x2}).Return(&ClientConn{
                                                                AutoReply: []byte(nil),
-                                                               Flags:     []byte{0, 0},
+                                                               Flags:     [2]byte{0, 0},
                                                        },
-                                               },
+                                                       )
+                                                       return &m
+                                               }(),
                                        },
                                },
                                t: NewTransaction(
                                        TranSendInstantMsg,
-                                       &[]byte{0, 1},
+                                       [2]byte{0, 1},
                                        NewField(FieldData, []byte("hai")),
                                        NewField(FieldUserID, []byte{0, 2}),
                                ),
                        },
                        wantRes: []Transaction{
-                               *NewTransaction(
+                               NewTransaction(
                                        TranServerMsg,
-                                       &[]byte{0, 2},
+                                       [2]byte{0, 2},
                                        NewField(FieldData, []byte("hai")),
                                        NewField(FieldUserName, []byte("User1")),
                                        NewField(FieldUserID, []byte{0, 1}),
                                        NewField(FieldOptions, []byte{0, 1}),
                                ),
                                {
-                                       clientID: &[]byte{0, 1},
+                                       clientID: [2]byte{0, 1},
                                        IsReply:  0x01,
                                        Fields:   []Field(nil),
                                },
                        },
-                       wantErr: assert.NoError,
                },
                {
                        name: "when client 2 has autoreply enabled",
@@ -2322,54 +2250,55 @@ func TestHandleSendInstantMsg(t *testing.T) {
                                        Account: &Account{
                                                Access: func() accessBitmap {
                                                        var bits accessBitmap
-                                                       bits.Set(accessSendPrivMsg)
+                                                       bits.Set(AccessSendPrivMsg)
                                                        return bits
                                                }(),
                                        },
-                                       ID:       &[]byte{0, 1},
+                                       ID:       [2]byte{0, 1},
                                        UserName: []byte("User1"),
                                        Server: &Server{
-                                               Clients: map[uint16]*ClientConn{
-                                                       uint16(2): {
-                                                               Flags:     []byte{0, 0},
-                                                               ID:        &[]byte{0, 2},
+                                               ClientMgr: func() *MockClientMgr {
+                                                       m := MockClientMgr{}
+                                                       m.On("Get", ClientID{0x0, 0x2}).Return(&ClientConn{
+                                                               Flags:     [2]byte{0, 0},
+                                                               ID:        [2]byte{0, 2},
                                                                UserName:  []byte("User2"),
                                                                AutoReply: []byte("autohai"),
-                                                       },
-                                               },
+                                                       })
+                                                       return &m
+                                               }(),
                                        },
                                },
                                t: NewTransaction(
                                        TranSendInstantMsg,
-                                       &[]byte{0, 1},
+                                       [2]byte{0, 1},
                                        NewField(FieldData, []byte("hai")),
                                        NewField(FieldUserID, []byte{0, 2}),
                                ),
                        },
                        wantRes: []Transaction{
-                               *NewTransaction(
+                               NewTransaction(
                                        TranServerMsg,
-                                       &[]byte{0, 2},
+                                       [2]byte{0, 2},
                                        NewField(FieldData, []byte("hai")),
                                        NewField(FieldUserName, []byte("User1")),
                                        NewField(FieldUserID, []byte{0, 1}),
                                        NewField(FieldOptions, []byte{0, 1}),
                                ),
-                               *NewTransaction(
+                               NewTransaction(
                                        TranServerMsg,
-                                       &[]byte{0, 1},
+                                       [2]byte{0, 1},
                                        NewField(FieldData, []byte("autohai")),
                                        NewField(FieldUserName, []byte("User2")),
                                        NewField(FieldUserID, []byte{0, 2}),
                                        NewField(FieldOptions, []byte{0, 1}),
                                ),
                                {
-                                       clientID: &[]byte{0, 1},
+                                       clientID: [2]byte{0, 1},
                                        IsReply:  0x01,
                                        Fields:   []Field(nil),
                                },
                        },
-                       wantErr: assert.NoError,
                },
                {
                        name: "when client 2 has refuse private messages enabled",
@@ -2378,54 +2307,52 @@ func TestHandleSendInstantMsg(t *testing.T) {
                                        Account: &Account{
                                                Access: func() accessBitmap {
                                                        var bits accessBitmap
-                                                       bits.Set(accessSendPrivMsg)
+                                                       bits.Set(AccessSendPrivMsg)
                                                        return bits
                                                }(),
                                        },
-                                       ID:       &[]byte{0, 1},
+                                       ID:       [2]byte{0, 1},
                                        UserName: []byte("User1"),
                                        Server: &Server{
-                                               Clients: map[uint16]*ClientConn{
-                                                       uint16(2): {
-                                                               Flags:    []byte{255, 255},
-                                                               ID:       &[]byte{0, 2},
+                                               ClientMgr: func() *MockClientMgr {
+                                                       m := MockClientMgr{}
+                                                       m.On("Get", ClientID{0x0, 0x2}).Return(&ClientConn{
+                                                               Flags:    [2]byte{255, 255},
+                                                               ID:       [2]byte{0, 2},
                                                                UserName: []byte("User2"),
                                                        },
-                                               },
+                                                       )
+                                                       return &m
+                                               }(),
                                        },
                                },
                                t: NewTransaction(
                                        TranSendInstantMsg,
-                                       &[]byte{0, 1},
+                                       [2]byte{0, 1},
                                        NewField(FieldData, []byte("hai")),
                                        NewField(FieldUserID, []byte{0, 2}),
                                ),
                        },
                        wantRes: []Transaction{
-                               *NewTransaction(
+                               NewTransaction(
                                        TranServerMsg,
-                                       &[]byte{0, 1},
+                                       [2]byte{0, 1},
                                        NewField(FieldData, []byte("User2 does not accept private messages.")),
                                        NewField(FieldUserName, []byte("User2")),
                                        NewField(FieldUserID, []byte{0, 2}),
                                        NewField(FieldOptions, []byte{0, 2}),
                                ),
                                {
-                                       clientID: &[]byte{0, 1},
+                                       clientID: [2]byte{0, 1},
                                        IsReply:  0x01,
                                        Fields:   []Field(nil),
                                },
                        },
-                       wantErr: assert.NoError,
                },
        }
        for _, tt := range tests {
                t.Run(tt.name, func(t *testing.T) {
-                       gotRes, err := HandleSendInstantMsg(tt.args.cc, tt.args.t)
-                       if !tt.wantErr(t, err, fmt.Sprintf("HandleSendInstantMsg(%v, %v)", tt.args.cc, tt.args.t)) {
-                               return
-                       }
-
+                       gotRes := HandleSendInstantMsg(tt.args.cc, &tt.args.t)
                        tranAssertEqual(t, tt.wantRes, gotRes)
                })
        }
@@ -2434,13 +2361,12 @@ func TestHandleSendInstantMsg(t *testing.T) {
 func TestHandleDeleteFile(t *testing.T) {
        type args struct {
                cc *ClientConn
-               t  *Transaction
+               t  Transaction
        }
        tests := []struct {
                name    string
                args    args
                wantRes []Transaction
-               wantErr assert.ErrorAssertionFunc
        }{
                {
                        name: "when user does not have required permission to delete a folder",
@@ -2453,7 +2379,7 @@ func TestHandleDeleteFile(t *testing.T) {
                                                }(),
                                        },
                                        Server: &Server{
-                                               Config: &Config{
+                                               Config: Config{
                                                        FileRoot: func() string {
                                                                return "/fakeRoot/Files"
                                                        }(),
@@ -2473,11 +2399,11 @@ func TestHandleDeleteFile(t *testing.T) {
 
                                                        return mfs
                                                }(),
-                                               Accounts: map[string]*Account{},
+                                               //Accounts: map[string]*Account{},
                                        },
                                },
                                t: NewTransaction(
-                                       TranDeleteFile, &[]byte{0, 1},
+                                       TranDeleteFile, [2]byte{0, 1},
                                        NewField(FieldFileName, []byte("testfile")),
                                        NewField(FieldFilePath, []byte{
                                                0x00, 0x01,
@@ -2496,7 +2422,6 @@ func TestHandleDeleteFile(t *testing.T) {
                                        },
                                },
                        },
-                       wantErr: assert.NoError,
                },
                {
                        name: "deletes all associated metadata files",
@@ -2505,12 +2430,12 @@ func TestHandleDeleteFile(t *testing.T) {
                                        Account: &Account{
                                                Access: func() accessBitmap {
                                                        var bits accessBitmap
-                                                       bits.Set(accessDeleteFile)
+                                                       bits.Set(AccessDeleteFile)
                                                        return bits
                                                }(),
                                        },
                                        Server: &Server{
-                                               Config: &Config{
+                                               Config: Config{
                                                        FileRoot: func() string {
                                                                return "/fakeRoot/Files"
                                                        }(),
@@ -2535,11 +2460,11 @@ func TestHandleDeleteFile(t *testing.T) {
 
                                                        return mfs
                                                }(),
-                                               Accounts: map[string]*Account{},
+                                               //Accounts: map[string]*Account{},
                                        },
                                },
                                t: NewTransaction(
-                                       TranDeleteFile, &[]byte{0, 1},
+                                       TranDeleteFile, [2]byte{0, 1},
                                        NewField(FieldFileName, []byte("testfile")),
                                        NewField(FieldFilePath, []byte{
                                                0x00, 0x01,
@@ -2555,16 +2480,11 @@ func TestHandleDeleteFile(t *testing.T) {
                                        Fields:  []Field(nil),
                                },
                        },
-                       wantErr: assert.NoError,
                },
        }
        for _, tt := range tests {
                t.Run(tt.name, func(t *testing.T) {
-                       gotRes, err := HandleDeleteFile(tt.args.cc, tt.args.t)
-                       if !tt.wantErr(t, err, fmt.Sprintf("HandleDeleteFile(%v, %v)", tt.args.cc, tt.args.t)) {
-                               return
-                       }
-
+                       gotRes := HandleDeleteFile(tt.args.cc, &tt.args.t)
                        tranAssertEqual(t, tt.wantRes, gotRes)
 
                        tt.args.cc.Server.FS.(*MockFileStore).AssertExpectations(t)
@@ -2575,16 +2495,15 @@ func TestHandleDeleteFile(t *testing.T) {
 func TestHandleGetFileNameList(t *testing.T) {
        type args struct {
                cc *ClientConn
-               t  *Transaction
+               t  Transaction
        }
        tests := []struct {
                name    string
                args    args
                wantRes []Transaction
-               wantErr assert.ErrorAssertionFunc
        }{
                {
-                       name: "when FieldFilePath is a drop box, but user does not have accessViewDropBoxes ",
+                       name: "when FieldFilePath is a drop box, but user does not have AccessViewDropBoxes ",
                        args: args{
                                cc: &ClientConn{
                                        Account: &Account{
@@ -2595,7 +2514,7 @@ func TestHandleGetFileNameList(t *testing.T) {
                                        },
                                        Server: &Server{
 
-                                               Config: &Config{
+                                               Config: Config{
                                                        FileRoot: func() string {
                                                                path, _ := os.Getwd()
                                                                return filepath.Join(path, "/test/config/Files/getFileNameListTestDir")
@@ -2604,7 +2523,7 @@ func TestHandleGetFileNameList(t *testing.T) {
                                        },
                                },
                                t: NewTransaction(
-                                       TranGetFileNameList, &[]byte{0, 1},
+                                       TranGetFileNameList, [2]byte{0, 1},
                                        NewField(FieldFilePath, []byte{
                                                0x00, 0x01,
                                                0x00, 0x00,
@@ -2622,14 +2541,13 @@ func TestHandleGetFileNameList(t *testing.T) {
                                        },
                                },
                        },
-                       wantErr: assert.NoError,
                },
                {
                        name: "with file root",
                        args: args{
                                cc: &ClientConn{
                                        Server: &Server{
-                                               Config: &Config{
+                                               Config: Config{
                                                        FileRoot: func() string {
                                                                path, _ := os.Getwd()
                                                                return filepath.Join(path, "/test/config/Files/getFileNameListTestDir")
@@ -2638,7 +2556,7 @@ func TestHandleGetFileNameList(t *testing.T) {
                                        },
                                },
                                t: NewTransaction(
-                                       TranGetFileNameList, &[]byte{0, 1},
+                                       TranGetFileNameList, [2]byte{0, 1},
                                        NewField(FieldFilePath, []byte{
                                                0x00, 0x00,
                                                0x00, 0x00,
@@ -2670,16 +2588,11 @@ func TestHandleGetFileNameList(t *testing.T) {
                                        },
                                },
                        },
-                       wantErr: assert.NoError,
                },
        }
        for _, tt := range tests {
                t.Run(tt.name, func(t *testing.T) {
-                       gotRes, err := HandleGetFileNameList(tt.args.cc, tt.args.t)
-                       if !tt.wantErr(t, err, fmt.Sprintf("HandleGetFileNameList(%v, %v)", tt.args.cc, tt.args.t)) {
-                               return
-                       }
-
+                       gotRes := HandleGetFileNameList(tt.args.cc, &tt.args.t)
                        tranAssertEqual(t, tt.wantRes, gotRes)
                })
        }
@@ -2688,13 +2601,12 @@ func TestHandleGetFileNameList(t *testing.T) {
 func TestHandleGetClientInfoText(t *testing.T) {
        type args struct {
                cc *ClientConn
-               t  *Transaction
+               t  Transaction
        }
        tests := []struct {
                name    string
                args    args
                wantRes []Transaction
-               wantErr assert.ErrorAssertionFunc
        }{
                {
                        name: "when user does not have required permission",
@@ -2707,11 +2619,11 @@ func TestHandleGetClientInfoText(t *testing.T) {
                                                }(),
                                        },
                                        Server: &Server{
-                                               Accounts: map[string]*Account{},
+                                               //Accounts: map[string]*Account{},
                                        },
                                },
                                t: NewTransaction(
-                                       TranGetClientInfoText, &[]byte{0, 1},
+                                       TranGetClientInfoText, [2]byte{0, 1},
                                        NewField(FieldUserID, []byte{0, 1}),
                                ),
                        },
@@ -2724,7 +2636,6 @@ func TestHandleGetClientInfoText(t *testing.T) {
                                        },
                                },
                        },
-                       wantErr: assert.NoError,
                },
                {
                        name: "with a valid user",
@@ -2735,39 +2646,36 @@ func TestHandleGetClientInfoText(t *testing.T) {
                                        Account: &Account{
                                                Access: func() accessBitmap {
                                                        var bits accessBitmap
-                                                       bits.Set(accessGetClientInfo)
+                                                       bits.Set(AccessGetClientInfo)
                                                        return bits
                                                }(),
                                                Name:  "test",
                                                Login: "test",
                                        },
                                        Server: &Server{
-                                               Accounts: map[string]*Account{},
-                                               Clients: map[uint16]*ClientConn{
-                                                       uint16(1): {
+                                               ClientMgr: func() *MockClientMgr {
+                                                       m := MockClientMgr{}
+                                                       m.On("Get", ClientID{0x0, 0x1}).Return(&ClientConn{
                                                                UserName:   []byte("Testy McTest"),
                                                                RemoteAddr: "1.2.3.4:12345",
                                                                Account: &Account{
                                                                        Access: func() accessBitmap {
                                                                                var bits accessBitmap
-                                                                               bits.Set(accessGetClientInfo)
+                                                                               bits.Set(AccessGetClientInfo)
                                                                                return bits
                                                                        }(),
                                                                        Name:  "test",
                                                                        Login: "test",
                                                                },
                                                        },
-                                               },
-                                       },
-                                       transfers: map[int]map[[4]byte]*FileTransfer{
-                                               FileDownload:   {},
-                                               FileUpload:     {},
-                                               FolderDownload: {},
-                                               FolderUpload:   {},
+                                                       )
+                                                       return &m
+                                               }(),
                                        },
+                                       ClientFileTransferMgr: ClientFileTransferMgr{},
                                },
                                t: NewTransaction(
-                                       TranGetClientInfoText, &[]byte{0, 1},
+                                       TranGetClientInfoText, [2]byte{0, 1},
                                        NewField(FieldUserID, []byte{0, 1}),
                                ),
                        },
@@ -2807,15 +2715,11 @@ None.
                                        },
                                },
                        },
-                       wantErr: assert.NoError,
                },
        }
        for _, tt := range tests {
                t.Run(tt.name, func(t *testing.T) {
-                       gotRes, err := HandleGetClientInfoText(tt.args.cc, tt.args.t)
-                       if !tt.wantErr(t, err, fmt.Sprintf("HandleGetClientInfoText(%v, %v)", tt.args.cc, tt.args.t)) {
-                               return
-                       }
+                       gotRes := HandleGetClientInfoText(tt.args.cc, &tt.args.t)
                        tranAssertEqual(t, tt.wantRes, gotRes)
                })
        }
@@ -2824,13 +2728,12 @@ None.
 func TestHandleTranAgreed(t *testing.T) {
        type args struct {
                cc *ClientConn
-               t  *Transaction
+               t  Transaction
        }
        tests := []struct {
                name    string
                args    args
                wantRes []Transaction
-               wantErr assert.ErrorAssertionFunc
        }{
                {
                        name: "normal request flow",
@@ -2839,23 +2742,34 @@ func TestHandleTranAgreed(t *testing.T) {
                                        Account: &Account{
                                                Access: func() accessBitmap {
                                                        var bits accessBitmap
-                                                       bits.Set(accessDisconUser)
-                                                       bits.Set(accessAnyName)
+                                                       bits.Set(AccessDisconUser)
+                                                       bits.Set(AccessAnyName)
                                                        return bits
                                                }()},
                                        Icon:    []byte{0, 1},
-                                       Flags:   []byte{0, 1},
+                                       Flags:   [2]byte{0, 1},
                                        Version: []byte{0, 1},
-                                       ID:      &[]byte{0, 1},
+                                       ID:      [2]byte{0, 1},
                                        logger:  NewTestLogger(),
                                        Server: &Server{
-                                               Config: &Config{
+                                               Config: Config{
                                                        BannerFile: "banner.jpg",
                                                },
+                                               ClientMgr: func() *MockClientMgr {
+                                                       m := MockClientMgr{}
+                                                       m.On("List").Return([]*ClientConn{
+                                                               //{
+                                                               //      ID:       [2]byte{0, 2},
+                                                               //      UserName: []byte("UserB"),
+                                                               //},
+                                                       },
+                                                       )
+                                                       return &m
+                                               }(),
                                        },
                                },
                                t: NewTransaction(
-                                       TranAgreed, nil,
+                                       TranAgreed, [2]byte{},
                                        NewField(FieldUserName, []byte("username")),
                                        NewField(FieldUserIconID, []byte{0, 1}),
                                        NewField(FieldOptions, []byte{0, 0}),
@@ -2863,27 +2777,23 @@ func TestHandleTranAgreed(t *testing.T) {
                        },
                        wantRes: []Transaction{
                                {
-                                       clientID: &[]byte{0, 1},
+                                       clientID: [2]byte{0, 1},
                                        Type:     [2]byte{0, 0x7a},
                                        Fields: []Field{
                                                NewField(FieldBannerType, []byte("JPEG")),
                                        },
                                },
                                {
-                                       clientID: &[]byte{0, 1},
+                                       clientID: [2]byte{0, 1},
                                        IsReply:  0x01,
                                        Fields:   []Field{},
                                },
                        },
-                       wantErr: assert.NoError,
                },
        }
        for _, tt := range tests {
                t.Run(tt.name, func(t *testing.T) {
-                       gotRes, err := HandleTranAgreed(tt.args.cc, tt.args.t)
-                       if !tt.wantErr(t, err, fmt.Sprintf("HandleTranAgreed(%v, %v)", tt.args.cc, tt.args.t)) {
-                               return
-                       }
+                       gotRes := HandleTranAgreed(tt.args.cc, &tt.args.t)
                        tranAssertEqual(t, tt.wantRes, gotRes)
                })
        }
@@ -2892,16 +2802,15 @@ func TestHandleTranAgreed(t *testing.T) {
 func TestHandleSetClientUserInfo(t *testing.T) {
        type args struct {
                cc *ClientConn
-               t  *Transaction
+               t  Transaction
        }
        tests := []struct {
                name    string
                args    args
                wantRes []Transaction
-               wantErr assert.ErrorAssertionFunc
        }{
                {
-                       name: "when client does not have accessAnyName",
+                       name: "when client does not have AccessAnyName",
                        args: args{
                                cc: &ClientConn{
                                        Account: &Account{
@@ -2910,26 +2819,30 @@ func TestHandleSetClientUserInfo(t *testing.T) {
                                                        return bits
                                                }(),
                                        },
-                                       ID:       &[]byte{0, 1},
+                                       ID:       [2]byte{0, 1},
                                        UserName: []byte("Guest"),
-                                       Flags:    []byte{0, 1},
+                                       Flags:    [2]byte{0, 1},
                                        Server: &Server{
-                                               Clients: map[uint16]*ClientConn{
-                                                       uint16(1): {
-                                                               ID: &[]byte{0, 1},
-                                                       },
-                                               },
+                                               ClientMgr: func() *MockClientMgr {
+                                                       m := MockClientMgr{}
+                                                       m.On("List").Return([]*ClientConn{
+                                                               {
+                                                                       ID: [2]byte{0, 1},
+                                                               },
+                                                       })
+                                                       return &m
+                                               }(),
                                        },
                                },
                                t: NewTransaction(
-                                       TranSetClientUserInfo, nil,
+                                       TranSetClientUserInfo, [2]byte{},
                                        NewField(FieldUserIconID, []byte{0, 1}),
                                        NewField(FieldUserName, []byte("NOPE")),
                                ),
                        },
                        wantRes: []Transaction{
                                {
-                                       clientID: &[]byte{0, 1},
+                                       clientID: [2]byte{0, 1},
                                        Type:     [2]byte{0x01, 0x2d},
                                        Fields: []Field{
                                                NewField(FieldUserID, []byte{0, 1}),
@@ -2938,16 +2851,11 @@ func TestHandleSetClientUserInfo(t *testing.T) {
                                                NewField(FieldUserName, []byte("Guest"))},
                                },
                        },
-                       wantErr: assert.NoError,
                },
        }
        for _, tt := range tests {
                t.Run(tt.name, func(t *testing.T) {
-                       gotRes, err := HandleSetClientUserInfo(tt.args.cc, tt.args.t)
-                       if !tt.wantErr(t, err, fmt.Sprintf("HandleSetClientUserInfo(%v, %v)", tt.args.cc, tt.args.t)) {
-                               return
-                       }
-
+                       gotRes := HandleSetClientUserInfo(tt.args.cc, &tt.args.t)
                        tranAssertEqual(t, tt.wantRes, gotRes)
                })
        }
@@ -2956,13 +2864,12 @@ func TestHandleSetClientUserInfo(t *testing.T) {
 func TestHandleDelNewsItem(t *testing.T) {
        type args struct {
                cc *ClientConn
-               t  *Transaction
+               t  Transaction
        }
        tests := []struct {
                name    string
                args    args
                wantRes []Transaction
-               wantErr assert.ErrorAssertionFunc
        }{
                {
                        name: "when user does not have permission to delete a news category",
@@ -2971,18 +2878,19 @@ func TestHandleDelNewsItem(t *testing.T) {
                                        Account: &Account{
                                                Access: accessBitmap{},
                                        },
-                                       ID: &[]byte{0, 1},
+                                       ID: [2]byte{0, 1},
                                        Server: &Server{
-                                               ThreadedNews: &ThreadedNews{Categories: map[string]NewsCategoryListData15{
-                                                       "test": {
-                                                               Type: [2]byte{0, 3},
-                                                               Name: "zz",
-                                                       },
-                                               }},
+                                               ThreadedNewsMgr: func() *mockThreadNewsMgr {
+                                                       m := mockThreadNewsMgr{}
+                                                       m.On("NewsItem", []string{"test"}).Return(NewsCategoryListData15{
+                                                               Type: NewsCategory,
+                                                       })
+                                                       return &m
+                                               }(),
                                        },
                                },
                                t: NewTransaction(
-                                       TranDelNewsItem, nil,
+                                       TranDelNewsItem, [2]byte{},
                                        NewField(FieldNewsPath,
                                                []byte{
                                                        0, 1,
@@ -2995,7 +2903,7 @@ func TestHandleDelNewsItem(t *testing.T) {
                        },
                        wantRes: []Transaction{
                                {
-                                       clientID:  &[]byte{0, 1},
+                                       clientID:  [2]byte{0, 1},
                                        IsReply:   0x01,
                                        ErrorCode: [4]byte{0, 0, 0, 1},
                                        Fields: []Field{
@@ -3003,7 +2911,6 @@ func TestHandleDelNewsItem(t *testing.T) {
                                        },
                                },
                        },
-                       wantErr: assert.NoError,
                },
                {
                        name: "when user does not have permission to delete a news folder",
@@ -3012,18 +2919,19 @@ func TestHandleDelNewsItem(t *testing.T) {
                                        Account: &Account{
                                                Access: accessBitmap{},
                                        },
-                                       ID: &[]byte{0, 1},
+                                       ID: [2]byte{0, 1},
                                        Server: &Server{
-                                               ThreadedNews: &ThreadedNews{Categories: map[string]NewsCategoryListData15{
-                                                       "testcat": {
-                                                               Type: [2]byte{0, 2},
-                                                               Name: "test",
-                                                       },
-                                               }},
+                                               ThreadedNewsMgr: func() *mockThreadNewsMgr {
+                                                       m := mockThreadNewsMgr{}
+                                                       m.On("NewsItem", []string{"test"}).Return(NewsCategoryListData15{
+                                                               Type: NewsBundle,
+                                                       })
+                                                       return &m
+                                               }(),
                                        },
                                },
                                t: NewTransaction(
-                                       TranDelNewsItem, nil,
+                                       TranDelNewsItem, [2]byte{},
                                        NewField(FieldNewsPath,
                                                []byte{
                                                        0, 1,
@@ -3036,7 +2944,7 @@ func TestHandleDelNewsItem(t *testing.T) {
                        },
                        wantRes: []Transaction{
                                {
-                                       clientID:  &[]byte{0, 1},
+                                       clientID:  [2]byte{0, 1},
                                        IsReply:   0x01,
                                        ErrorCode: [4]byte{0, 0, 0, 1},
                                        Fields: []Field{
@@ -3044,7 +2952,6 @@ func TestHandleDelNewsItem(t *testing.T) {
                                        },
                                },
                        },
-                       wantErr: assert.NoError,
                },
                {
                        name: "when user deletes a news folder",
@@ -3053,28 +2960,22 @@ func TestHandleDelNewsItem(t *testing.T) {
                                        Account: &Account{
                                                Access: func() accessBitmap {
                                                        var bits accessBitmap
-                                                       bits.Set(accessNewsDeleteFldr)
+                                                       bits.Set(AccessNewsDeleteFldr)
                                                        return bits
                                                }(),
                                        },
-                                       ID: &[]byte{0, 1},
+                                       ID: [2]byte{0, 1},
                                        Server: &Server{
-                                               ConfigDir: "/fakeConfigRoot",
-                                               FS: func() *MockFileStore {
-                                                       mfs := &MockFileStore{}
-                                                       mfs.On("WriteFile", "/fakeConfigRoot/ThreadedNews.yaml", mock.Anything, mock.Anything).Return(nil, os.ErrNotExist)
-                                                       return mfs
+                                               ThreadedNewsMgr: func() *mockThreadNewsMgr {
+                                                       m := mockThreadNewsMgr{}
+                                                       m.On("NewsItem", []string{"test"}).Return(NewsCategoryListData15{Type: NewsBundle})
+                                                       m.On("DeleteNewsItem", []string{"test"}).Return(nil)
+                                                       return &m
                                                }(),
-                                               ThreadedNews: &ThreadedNews{Categories: map[string]NewsCategoryListData15{
-                                                       "testcat": {
-                                                               Type: [2]byte{0, 2},
-                                                               Name: "test",
-                                                       },
-                                               }},
                                        },
                                },
                                t: NewTransaction(
-                                       TranDelNewsItem, nil,
+                                       TranDelNewsItem, [2]byte{},
                                        NewField(FieldNewsPath,
                                                []byte{
                                                        0, 1,
@@ -3087,20 +2988,17 @@ func TestHandleDelNewsItem(t *testing.T) {
                        },
                        wantRes: []Transaction{
                                {
-                                       clientID: &[]byte{0, 1},
+                                       clientID: [2]byte{0, 1},
                                        IsReply:  0x01,
                                        Fields:   []Field{},
                                },
                        },
-                       wantErr: assert.NoError,
                },
        }
        for _, tt := range tests {
                t.Run(tt.name, func(t *testing.T) {
-                       gotRes, err := HandleDelNewsItem(tt.args.cc, tt.args.t)
-                       if !tt.wantErr(t, err, fmt.Sprintf("HandleDelNewsItem(%v, %v)", tt.args.cc, tt.args.t)) {
-                               return
-                       }
+                       gotRes := HandleDelNewsItem(tt.args.cc, &tt.args.t)
+
                        tranAssertEqual(t, tt.wantRes, gotRes)
                })
        }
@@ -3109,27 +3007,23 @@ func TestHandleDelNewsItem(t *testing.T) {
 func TestHandleTranOldPostNews(t *testing.T) {
        type args struct {
                cc *ClientConn
-               t  *Transaction
+               t  Transaction
        }
        tests := []struct {
                name    string
                args    args
                wantRes []Transaction
-               wantErr assert.ErrorAssertionFunc
        }{
                {
                        name: "when user does not have required permission",
                        args: args{
                                cc: &ClientConn{
                                        Account: &Account{
-                                               Access: func() accessBitmap {
-                                                       var bits accessBitmap
-                                                       return bits
-                                               }(),
+                                               Access: accessBitmap{},
                                        },
                                },
                                t: NewTransaction(
-                                       TranOldPostNews, &[]byte{0, 1},
+                                       TranOldPostNews, [2]byte{0, 1},
                                        NewField(FieldData, []byte("hai")),
                                ),
                        },
@@ -3142,7 +3036,6 @@ func TestHandleTranOldPostNews(t *testing.T) {
                                        },
                                },
                        },
-                       wantErr: assert.NoError,
                },
                {
                        name: "when user posts news update",
@@ -3151,22 +3044,33 @@ func TestHandleTranOldPostNews(t *testing.T) {
                                        Account: &Account{
                                                Access: func() accessBitmap {
                                                        var bits accessBitmap
-                                                       bits.Set(accessNewsPostArt)
+                                                       bits.Set(AccessNewsPostArt)
                                                        return bits
                                                }(),
                                        },
                                        Server: &Server{
-                                               FS: func() *MockFileStore {
-                                                       mfs := &MockFileStore{}
-                                                       mfs.On("WriteFile", "/fakeConfigRoot/MessageBoard.txt", mock.Anything, mock.Anything).Return(nil, os.ErrNotExist)
-                                                       return mfs
+                                               Config: Config{
+                                                       NewsDateFormat: "",
+                                               },
+                                               ClientMgr: func() *MockClientMgr {
+                                                       m := MockClientMgr{}
+                                                       m.On("List").Return([]*ClientConn{})
+                                                       return &m
+                                               }(),
+                                               MessageBoard: func() *mockReadWriteSeeker {
+                                                       m := mockReadWriteSeeker{}
+                                                       m.On("Seek", int64(0), 0).Return(int64(0), nil)
+                                                       m.On("Read", mock.AnythingOfType("[]uint8")).Run(func(args mock.Arguments) {
+                                                               arg := args.Get(0).([]uint8)
+                                                               copy(arg, "TEST")
+                                                       }).Return(4, io.EOF)
+                                                       m.On("Write", mock.AnythingOfType("[]uint8")).Return(3, nil)
+                                                       return &m
                                                }(),
-                                               ConfigDir: "/fakeConfigRoot",
-                                               Config:    &Config{},
                                        },
                                },
                                t: NewTransaction(
-                                       TranOldPostNews, &[]byte{0, 1},
+                                       TranOldPostNews, [2]byte{0, 1},
                                        NewField(FieldData, []byte("hai")),
                                ),
                        },
@@ -3175,15 +3079,11 @@ func TestHandleTranOldPostNews(t *testing.T) {
                                        IsReply: 0x01,
                                },
                        },
-                       wantErr: assert.NoError,
                },
        }
        for _, tt := range tests {
                t.Run(tt.name, func(t *testing.T) {
-                       gotRes, err := HandleTranOldPostNews(tt.args.cc, tt.args.t)
-                       if !tt.wantErr(t, err, fmt.Sprintf("HandleTranOldPostNews(%v, %v)", tt.args.cc, tt.args.t)) {
-                               return
-                       }
+                       gotRes := HandleTranOldPostNews(tt.args.cc, &tt.args.t)
 
                        tranAssertEqual(t, tt.wantRes, gotRes)
                })
@@ -3193,13 +3093,12 @@ func TestHandleTranOldPostNews(t *testing.T) {
 func TestHandleInviteNewChat(t *testing.T) {
        type args struct {
                cc *ClientConn
-               t  *Transaction
+               t  Transaction
        }
        tests := []struct {
                name    string
                args    args
                wantRes []Transaction
-               wantErr assert.ErrorAssertionFunc
        }{
                {
                        name: "when user does not have required permission",
@@ -3212,7 +3111,7 @@ func TestHandleInviteNewChat(t *testing.T) {
                                                }(),
                                        },
                                },
-                               t: NewTransaction(TranInviteNewChat, &[]byte{0, 1}),
+                               t: NewTransaction(TranInviteNewChat, [2]byte{0, 1}),
                        },
                        wantRes: []Transaction{
                                {
@@ -3223,42 +3122,46 @@ func TestHandleInviteNewChat(t *testing.T) {
                                        },
                                },
                        },
-                       wantErr: assert.NoError,
                },
                {
                        name: "when userA invites userB to new private chat",
                        args: args{
                                cc: &ClientConn{
-                                       ID: &[]byte{0, 1},
+                                       ID: [2]byte{0, 1},
                                        Account: &Account{
                                                Access: func() accessBitmap {
                                                        var bits accessBitmap
-                                                       bits.Set(accessOpenChat)
+                                                       bits.Set(AccessOpenChat)
                                                        return bits
                                                }(),
                                        },
                                        UserName: []byte("UserA"),
                                        Icon:     []byte{0, 1},
-                                       Flags:    []byte{0, 0},
+                                       Flags:    [2]byte{0, 0},
                                        Server: &Server{
-                                               Clients: map[uint16]*ClientConn{
-                                                       uint16(2): {
-                                                               ID:       &[]byte{0, 2},
+                                               ClientMgr: func() *MockClientMgr {
+                                                       m := MockClientMgr{}
+                                                       m.On("Get", ClientID{0x0, 0x2}).Return(&ClientConn{
+                                                               ID:       [2]byte{0, 2},
                                                                UserName: []byte("UserB"),
-                                                               Flags:    []byte{0, 0},
-                                                       },
-                                               },
-                                               PrivateChats: make(map[uint32]*PrivateChat),
+                                                       })
+                                                       return &m
+                                               }(),
+                                               ChatMgr: func() *MockChatManager {
+                                                       m := MockChatManager{}
+                                                       m.On("New", mock.AnythingOfType("*hotline.ClientConn")).Return(ChatID{0x52, 0xfd, 0xfc, 0x07})
+                                                       return &m
+                                               }(),
                                        },
                                },
                                t: NewTransaction(
-                                       TranInviteNewChat, &[]byte{0, 1},
+                                       TranInviteNewChat, [2]byte{0, 1},
                                        NewField(FieldUserID, []byte{0, 2}),
                                ),
                        },
                        wantRes: []Transaction{
                                {
-                                       clientID: &[]byte{0, 2},
+                                       clientID: [2]byte{0, 2},
                                        Type:     [2]byte{0, 0x71},
                                        Fields: []Field{
                                                NewField(FieldChatID, []byte{0x52, 0xfd, 0xfc, 0x07}),
@@ -3266,9 +3169,8 @@ func TestHandleInviteNewChat(t *testing.T) {
                                                NewField(FieldUserID, []byte{0, 1}),
                                        },
                                },
-
                                {
-                                       clientID: &[]byte{0, 1},
+                                       clientID: [2]byte{0, 1},
                                        IsReply:  0x01,
                                        Fields: []Field{
                                                NewField(FieldChatID, []byte{0x52, 0xfd, 0xfc, 0x07}),
@@ -3279,42 +3181,48 @@ func TestHandleInviteNewChat(t *testing.T) {
                                        },
                                },
                        },
-                       wantErr: assert.NoError,
                },
                {
                        name: "when userA invites userB to new private chat, but UserB has refuse private chat enabled",
                        args: args{
                                cc: &ClientConn{
-                                       ID: &[]byte{0, 1},
+                                       ID: [2]byte{0, 1},
                                        Account: &Account{
                                                Access: func() accessBitmap {
                                                        var bits accessBitmap
-                                                       bits.Set(accessOpenChat)
+                                                       bits.Set(AccessOpenChat)
                                                        return bits
                                                }(),
                                        },
                                        UserName: []byte("UserA"),
                                        Icon:     []byte{0, 1},
-                                       Flags:    []byte{0, 0},
+                                       Flags:    [2]byte{0, 0},
                                        Server: &Server{
-                                               Clients: map[uint16]*ClientConn{
-                                                       uint16(2): {
-                                                               ID:       &[]byte{0, 2},
+                                               ClientMgr: func() *MockClientMgr {
+                                                       m := MockClientMgr{}
+                                                       m.On("Get", ClientID{0, 2}).Return(&ClientConn{
+                                                               ID:       [2]byte{0, 2},
+                                                               Icon:     []byte{0, 1},
                                                                UserName: []byte("UserB"),
-                                                               Flags:    []byte{255, 255},
-                                                       },
-                                               },
-                                               PrivateChats: make(map[uint32]*PrivateChat),
+                                                               Flags:    [2]byte{255, 255},
+                                                       })
+                                                       return &m
+                                               }(),
+                                               ChatMgr: func() *MockChatManager {
+                                                       m := MockChatManager{}
+                                                       m.On("New", mock.AnythingOfType("*hotline.ClientConn")).Return(ChatID{0x52, 0xfd, 0xfc, 0x07})
+                                                       return &m
+                                               }(),
                                        },
                                },
                                t: NewTransaction(
-                                       TranInviteNewChat, &[]byte{0, 1},
+                                       TranInviteNewChat, [2]byte{0, 1},
                                        NewField(FieldUserID, []byte{0, 2}),
                                ),
                        },
                        wantRes: []Transaction{
                                {
-                                       clientID: &[]byte{0, 1},
+                                       clientID: [2]byte{0, 1},
                                        Type:     [2]byte{0, 0x68},
                                        Fields: []Field{
                                                NewField(FieldData, []byte("UserB does not accept private chats.")),
@@ -3324,7 +3232,7 @@ func TestHandleInviteNewChat(t *testing.T) {
                                        },
                                },
                                {
-                                       clientID: &[]byte{0, 1},
+                                       clientID: [2]byte{0, 1},
                                        IsReply:  0x01,
                                        Fields: []Field{
                                                NewField(FieldChatID, []byte{0x52, 0xfd, 0xfc, 0x07}),
@@ -3335,15 +3243,13 @@ func TestHandleInviteNewChat(t *testing.T) {
                                        },
                                },
                        },
-                       wantErr: assert.NoError,
                },
        }
        for _, tt := range tests {
                t.Run(tt.name, func(t *testing.T) {
-                       gotRes, err := HandleInviteNewChat(tt.args.cc, tt.args.t)
-                       if !tt.wantErr(t, err, fmt.Sprintf("HandleInviteNewChat(%v, %v)", tt.args.cc, tt.args.t)) {
-                               return
-                       }
+
+                       gotRes := HandleInviteNewChat(tt.args.cc, &tt.args.t)
+
                        tranAssertEqual(t, tt.wantRes, gotRes)
                })
        }
@@ -3352,50 +3258,90 @@ func TestHandleInviteNewChat(t *testing.T) {
 func TestHandleGetNewsArtData(t *testing.T) {
        type args struct {
                cc *ClientConn
-               t  *Transaction
+               t  Transaction
        }
        tests := []struct {
                name    string
                args    args
                wantRes []Transaction
-               wantErr assert.ErrorAssertionFunc
        }{
                {
                        name: "when user does not have required permission",
+                       args: args{
+                               cc: &ClientConn{Account: &Account{}},
+                               t: NewTransaction(
+                                       TranGetNewsArtData, [2]byte{0, 1},
+                               ),
+                       },
+                       wantRes: []Transaction{
+                               {
+                                       IsReply:   0x01,
+                                       ErrorCode: [4]byte{0, 0, 0, 1},
+                                       Fields: []Field{
+                                               NewField(FieldError, []byte("You are not allowed to read news.")),
+                                       },
+                               },
+                       },
+               },
+               {
+                       name: "when user has required permission",
                        args: args{
                                cc: &ClientConn{
                                        Account: &Account{
                                                Access: func() accessBitmap {
                                                        var bits accessBitmap
+                                                       bits.Set(AccessNewsReadArt)
                                                        return bits
                                                }(),
                                        },
                                        Server: &Server{
-                                               Accounts: map[string]*Account{},
+                                               ThreadedNewsMgr: func() *mockThreadNewsMgr {
+                                                       m := mockThreadNewsMgr{}
+                                                       m.On("GetArticle", []string{"Example Category"}, uint32(1)).Return(&NewsArtData{
+                                                               Title:         "title",
+                                                               Poster:        "poster",
+                                                               Date:          [8]byte{},
+                                                               PrevArt:       [4]byte{0, 0, 0, 1},
+                                                               NextArt:       [4]byte{0, 0, 0, 2},
+                                                               ParentArt:     [4]byte{0, 0, 0, 3},
+                                                               FirstChildArt: [4]byte{0, 0, 0, 4},
+                                                               DataFlav:      []byte("text/plain"),
+                                                               Data:          "article data",
+                                                       })
+                                                       return &m
+                                               }(),
                                        },
                                },
                                t: NewTransaction(
-                                       TranGetNewsArtData, &[]byte{0, 1},
+                                       TranGetNewsArtData, [2]byte{0, 1},
+                                       NewField(FieldNewsPath, []byte{
+                                               // Example Category
+                                               0x00, 0x01, 0x00, 0x00, 0x10, 0x45, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x20, 0x43, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79,
+                                       }),
+                                       NewField(FieldNewsArtID, []byte{0, 1}),
                                ),
                        },
                        wantRes: []Transaction{
                                {
-                                       IsReply:   0x01,
-                                       ErrorCode: [4]byte{0, 0, 0, 1},
+                                       IsReply: 1,
                                        Fields: []Field{
-                                               NewField(FieldError, []byte("You are not allowed to read news.")),
+                                               NewField(FieldNewsArtTitle, []byte("title")),
+                                               NewField(FieldNewsArtPoster, []byte("poster")),
+                                               NewField(FieldNewsArtDate, []byte{0, 0, 0, 0, 0, 0, 0, 0}),
+                                               NewField(FieldNewsArtPrevArt, []byte{0, 0, 0, 1}),
+                                               NewField(FieldNewsArtNextArt, []byte{0, 0, 0, 2}),
+                                               NewField(FieldNewsArtParentArt, []byte{0, 0, 0, 3}),
+                                               NewField(FieldNewsArt1stChildArt, []byte{0, 0, 0, 4}),
+                                               NewField(FieldNewsArtDataFlav, []byte("text/plain")),
+                                               NewField(FieldNewsArtData, []byte("article data")),
                                        },
                                },
                        },
-                       wantErr: assert.NoError,
                },
        }
        for _, tt := range tests {
                t.Run(tt.name, func(t *testing.T) {
-                       gotRes, err := HandleGetNewsArtData(tt.args.cc, tt.args.t)
-                       if !tt.wantErr(t, err, fmt.Sprintf("HandleGetNewsArtData(%v, %v)", tt.args.cc, tt.args.t)) {
-                               return
-                       }
+                       gotRes := HandleGetNewsArtData(tt.args.cc, &tt.args.t)
                        tranAssertEqual(t, tt.wantRes, gotRes)
                })
        }
@@ -3404,13 +3350,12 @@ func TestHandleGetNewsArtData(t *testing.T) {
 func TestHandleGetNewsArtNameList(t *testing.T) {
        type args struct {
                cc *ClientConn
-               t  *Transaction
+               t  Transaction
        }
        tests := []struct {
                name    string
                args    args
                wantRes []Transaction
-               wantErr assert.ErrorAssertionFunc
        }{
                {
                        name: "when user does not have required permission",
@@ -3423,11 +3368,11 @@ func TestHandleGetNewsArtNameList(t *testing.T) {
                                                }(),
                                        },
                                        Server: &Server{
-                                               Accounts: map[string]*Account{},
+                                               //Accounts: map[string]*Account{},
                                        },
                                },
                                t: NewTransaction(
-                                       TranGetNewsArtNameList, &[]byte{0, 1},
+                                       TranGetNewsArtNameList, [2]byte{0, 1},
                                ),
                        },
                        wantRes: []Transaction{
@@ -3441,84 +3386,60 @@ func TestHandleGetNewsArtNameList(t *testing.T) {
                                        },
                                },
                        },
-                       wantErr: assert.NoError,
-               },
-               {
-                       name: "when user has required access",
-                       args: args{
-                               cc: &ClientConn{
-                                       Account: &Account{
-                                               Access: func() accessBitmap {
-                                                       var bits accessBitmap
-                                                       bits.Set(accessNewsReadArt)
-                                                       return bits
-                                               }(),
-                                       },
-                                       Server: &Server{
-                                               ThreadedNews: &ThreadedNews{
-                                                       Categories: map[string]NewsCategoryListData15{
-                                                               "Example Category": {
-                                                                       Type: [2]byte{0, 2},
-                                                                       Name: "",
-                                                                       Articles: map[uint32]*NewsArtData{
-                                                                               uint32(1): {
-                                                                                       Title:  "testTitle",
-                                                                                       Poster: "testPoster",
-                                                                                       Data:   "testBody",
-                                                                               },
-                                                                       },
-                                                                       SubCats:  nil,
-                                                                       GUID:     [16]byte{},
-                                                                       AddSN:    [4]byte{},
-                                                                       DeleteSN: [4]byte{},
-                                                               },
-                                                       },
-                                               },
-
-                                               //Accounts: map[string]*Account{
-                                               //      "guest": {
-                                               //              Name:     "guest",
-                                               //              Login:    "guest",
-                                               //              Password: "zz",
-                                               //              Access:   accessBitmap{255, 255, 255, 255, 255, 255, 255, 255},
-                                               //      },
-                                               //},
-                                       },
-                               },
-                               t: NewTransaction(
-                                       TranGetNewsArtNameList,
-                                       &[]byte{0, 1},
-                                       //  00000000  00 01 00 00 10 45 78 61  6d 70 6c 65 20 43 61 74  |.....Example Cat|
-                                       //  00000010  65 67 6f 72 79                                    |egory|
-                                       NewField(FieldNewsPath, []byte{
-                                               0x00, 0x01, 0x00, 0x00, 0x10, 0x45, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x20, 0x43, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79,
-                                       }),
-                               ),
-                       },
-                       wantRes: []Transaction{
-                               {
-                                       IsReply: 0x01,
-                                       Fields: []Field{
-                                               NewField(FieldNewsArtListData, []byte{
-                                                       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00,
-                                                       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
-                                                       0x09, 0x74, 0x65, 0x73, 0x74, 0x54, 0x69, 0x74, 0x6c, 0x65, 0x0a, 0x74, 0x65, 0x73, 0x74, 0x50,
-                                                       0x6f, 0x73, 0x74, 0x65, 0x72, 0x0a, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x70, 0x6c, 0x61, 0x69, 0x6e,
-                                                       0x00, 0x08,
-                                               },
-                                               ),
-                                       },
-                               },
-                       },
-                       wantErr: assert.NoError,
                },
+               //{
+               //      name: "when user has required access",
+               //      args: args{
+               //              cc: &ClientConn{
+               //                      Account: &Account{
+               //                              Access: func() accessBitmap {
+               //                                      var bits accessBitmap
+               //                                      bits.Set(AccessNewsReadArt)
+               //                                      return bits
+               //                              }(),
+               //                      },
+               //                      Server: &Server{
+               //                              ThreadedNewsMgr: func() *mockThreadNewsMgr {
+               //                                      m := mockThreadNewsMgr{}
+               //                                      m.On("ListArticles", []string{"Example Category"}).Return(NewsArtListData{
+               //                                              Name:        []byte("testTitle"),
+               //                                              NewsArtList: []byte{},
+               //                                      })
+               //                                      return &m
+               //                              }(),
+               //                      },
+               //              },
+               //              t: NewTransaction(
+               //                      TranGetNewsArtNameList,
+               //                      [2]byte{0, 1},
+               //                      //  00000000  00 01 00 00 10 45 78 61  6d 70 6c 65 20 43 61 74  |.....Example Cat|
+               //                      //  00000010  65 67 6f 72 79                                    |egory|
+               //                      NewField(FieldNewsPath, []byte{
+               //                              0x00, 0x01, 0x00, 0x00, 0x10, 0x45, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x20, 0x43, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79,
+               //                      }),
+               //              ),
+               //      },
+               //      wantRes: []Transaction{
+               //              {
+               //                      IsReply: 0x01,
+               //                      Fields: []Field{
+               //                              NewField(FieldNewsArtListData, []byte{
+               //                                      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00,
+               //                                      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
+               //                                      0x09, 0x74, 0x65, 0x73, 0x74, 0x54, 0x69, 0x74, 0x6c, 0x65, 0x0a, 0x74, 0x65, 0x73, 0x74, 0x50,
+               //                                      0x6f, 0x73, 0x74, 0x65, 0x72, 0x0a, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x70, 0x6c, 0x61, 0x69, 0x6e,
+               //                                      0x00, 0x08,
+               //                              },
+               //                              ),
+               //                      },
+               //              },
+               //      },
+               //},
        }
        for _, tt := range tests {
                t.Run(tt.name, func(t *testing.T) {
-                       gotRes, err := HandleGetNewsArtNameList(tt.args.cc, tt.args.t)
-                       if !tt.wantErr(t, err, fmt.Sprintf("HandleGetNewsArtNameList(%v, %v)", tt.args.cc, tt.args.t)) {
-                               return
-                       }
+                       gotRes := HandleGetNewsArtNameList(tt.args.cc, &tt.args.t)
+
                        tranAssertEqual(t, tt.wantRes, gotRes)
                })
        }
@@ -3527,13 +3448,12 @@ func TestHandleGetNewsArtNameList(t *testing.T) {
 func TestHandleNewNewsFldr(t *testing.T) {
        type args struct {
                cc *ClientConn
-               t  *Transaction
+               t  Transaction
        }
        tests := []struct {
                name    string
                args    args
                wantRes []Transaction
-               wantErr assert.ErrorAssertionFunc
        }{
                {
                        name: "when user does not have required permission",
@@ -3546,11 +3466,11 @@ func TestHandleNewNewsFldr(t *testing.T) {
                                                }(),
                                        },
                                        Server: &Server{
-                                               Accounts: map[string]*Account{},
+                                               //Accounts: map[string]*Account{},
                                        },
                                },
                                t: NewTransaction(
-                                       TranGetNewsArtNameList, &[]byte{0, 1},
+                                       TranGetNewsArtNameList, [2]byte{0, 1},
                                ),
                        },
                        wantRes: []Transaction{
@@ -3564,7 +3484,6 @@ func TestHandleNewNewsFldr(t *testing.T) {
                                        },
                                },
                        },
-                       wantErr: assert.NoError,
                },
                {
                        name: "with a valid request",
@@ -3573,30 +3492,22 @@ func TestHandleNewNewsFldr(t *testing.T) {
                                        Account: &Account{
                                                Access: func() accessBitmap {
                                                        var bits accessBitmap
-                                                       bits.Set(accessNewsCreateFldr)
+                                                       bits.Set(AccessNewsCreateFldr)
                                                        return bits
                                                }(),
                                        },
                                        logger: NewTestLogger(),
-                                       ID:     &[]byte{0, 1},
+                                       ID:     [2]byte{0, 1},
                                        Server: &Server{
-                                               ConfigDir: "/fakeConfigRoot",
-                                               FS: func() *MockFileStore {
-                                                       mfs := &MockFileStore{}
-                                                       mfs.On("WriteFile", "/fakeConfigRoot/ThreadedNews.yaml", mock.Anything, mock.Anything).Return(nil)
-                                                       return mfs
+                                               ThreadedNewsMgr: func() *mockThreadNewsMgr {
+                                                       m := mockThreadNewsMgr{}
+                                                       m.On("CreateGrouping", []string{"test"}, "testFolder", NewsBundle).Return(nil)
+                                                       return &m
                                                }(),
-                                               ThreadedNews: &ThreadedNews{Categories: map[string]NewsCategoryListData15{
-                                                       "test": {
-                                                               Type:    [2]byte{0, 2},
-                                                               Name:    "test",
-                                                               SubCats: make(map[string]NewsCategoryListData15),
-                                                       },
-                                               }},
                                        },
                                },
                                t: NewTransaction(
-                                       TranGetNewsArtNameList, &[]byte{0, 1},
+                                       TranGetNewsArtNameList, [2]byte{0, 1},
                                        NewField(FieldFileName, []byte("testFolder")),
                                        NewField(FieldNewsPath,
                                                []byte{
@@ -3610,12 +3521,11 @@ func TestHandleNewNewsFldr(t *testing.T) {
                        },
                        wantRes: []Transaction{
                                {
-                                       clientID: &[]byte{0, 1},
+                                       clientID: [2]byte{0, 1},
                                        IsReply:  0x01,
                                        Fields:   []Field{},
                                },
                        },
-                       wantErr: assert.NoError,
                },
                //{
                //      Name: "when there is an error writing the threaded news file",
@@ -3624,12 +3534,12 @@ func TestHandleNewNewsFldr(t *testing.T) {
                //                      Account: &Account{
                //                              Access: func() accessBitmap {
                //                                      var bits accessBitmap
-               //                                      bits.Set(accessNewsCreateFldr)
+               //                                      bits.Set(AccessNewsCreateFldr)
                //                                      return bits
                //                              }(),
                //                      },
                //                      logger: NewTestLogger(),
-               //                      ID:     &[]byte{0, 1},
+               //                      Type:     [2]byte{0, 1},
                //                      Server: &Server{
                //                              ConfigDir: "/fakeConfigRoot",
                //                              FS: func() *MockFileStore {
@@ -3649,7 +3559,7 @@ func TestHandleNewNewsFldr(t *testing.T) {
                //                      },
                //              },
                //              t: NewTransaction(
-               //                      TranGetNewsArtNameList, &[]byte{0, 1},
+               //                      TranGetNewsArtNameList, [2]byte{0, 1},
                //                      NewField(FieldFileName, []byte("testFolder")),
                //                      NewField(FieldNewsPath,
                //                              []byte{
@@ -3663,7 +3573,7 @@ func TestHandleNewNewsFldr(t *testing.T) {
                //      },
                //      wantRes: []Transaction{
                //              {
-               //                      clientID:  &[]byte{0, 1},
+               //                      clientID:  [2]byte{0, 1},
                //                      Flags:     0x00,
                //                      IsReply:   0x01,
                //                      Type:      [2]byte{0, 0},
@@ -3673,15 +3583,11 @@ func TestHandleNewNewsFldr(t *testing.T) {
                //                      },
                //              },
                //      },
-               //      wantErr: assert.Error,
-               // },
        }
        for _, tt := range tests {
                t.Run(tt.name, func(t *testing.T) {
-                       gotRes, err := HandleNewNewsFldr(tt.args.cc, tt.args.t)
-                       if !tt.wantErr(t, err, fmt.Sprintf("HandleNewNewsFldr(%v, %v)", tt.args.cc, tt.args.t)) {
-                               return
-                       }
+                       gotRes := HandleNewNewsFldr(tt.args.cc, &tt.args.t)
+
                        tranAssertEqual(t, tt.wantRes, gotRes)
                })
        }
@@ -3690,23 +3596,98 @@ func TestHandleNewNewsFldr(t *testing.T) {
 func TestHandleDownloadBanner(t *testing.T) {
        type args struct {
                cc *ClientConn
-               t  *Transaction
+               t  Transaction
        }
        tests := []struct {
                name    string
                args    args
                wantRes []Transaction
-               wantErr assert.ErrorAssertionFunc
        }{
                // TODO: Add test cases.
        }
        for _, tt := range tests {
                t.Run(tt.name, func(t *testing.T) {
-                       gotRes, err := HandleDownloadBanner(tt.args.cc, tt.args.t)
-                       if !tt.wantErr(t, err, fmt.Sprintf("HandleDownloadBanner(%v, %v)", tt.args.cc, tt.args.t)) {
-                               return
-                       }
-                       assert.Equalf(t, tt.wantRes, gotRes, "HandleDownloadBanner(%v, %v)", tt.args.cc, tt.args.t)
+                       gotRes := HandleDownloadBanner(tt.args.cc, &tt.args.t)
+
+                       assert.Equalf(t, tt.wantRes, gotRes, "HandleDownloadBanner(%v, %v)", tt.args.cc, &tt.args.t)
+               })
+       }
+}
+
+func TestHandlePostNewsArt(t *testing.T) {
+       type args struct {
+               cc *ClientConn
+               t  Transaction
+       }
+       tests := []struct {
+               name    string
+               args    args
+               wantRes []Transaction
+       }{
+               {
+                       name: "without required permission",
+                       args: args{
+                               cc: &ClientConn{
+                                       Account: &Account{
+                                               Access: func() accessBitmap {
+                                                       var bits accessBitmap
+                                                       return bits
+                                               }(),
+                                       },
+                               },
+                               t: NewTransaction(
+                                       TranPostNewsArt,
+                                       [2]byte{0, 0},
+                               ),
+                       },
+                       wantRes: []Transaction{
+                               {
+                                       IsReply:   0x01,
+                                       ErrorCode: [4]byte{0, 0, 0, 1},
+                                       Fields: []Field{
+                                               NewField(FieldError, []byte("You are not allowed to post news articles.")),
+                                       },
+                               },
+                       },
+               },
+               {
+                       name: "with required permission",
+                       args: args{
+                               cc: &ClientConn{
+                                       Server: &Server{
+                                               ThreadedNewsMgr: func() *mockThreadNewsMgr {
+                                                       m := mockThreadNewsMgr{}
+                                                       m.On("PostArticle", []string{"www"}, uint32(0), mock.AnythingOfType("hotline.NewsArtData")).Return(nil)
+                                                       return &m
+                                               }(),
+                                       },
+                                       Account: &Account{
+                                               Access: func() accessBitmap {
+                                                       var bits accessBitmap
+                                                       bits.Set(AccessNewsPostArt)
+                                                       return bits
+                                               }(),
+                                       },
+                               },
+                               t: NewTransaction(
+                                       TranPostNewsArt,
+                                       [2]byte{0, 0},
+                                       NewField(FieldNewsPath, []byte{0x00, 0x01, 0x00, 0x00, 0x03, 0x77, 0x77, 0x77}),
+                                       NewField(FieldNewsArtID, []byte{0x00, 0x00, 0x00, 0x00}),
+                               ),
+                       },
+                       wantRes: []Transaction{
+                               {
+                                       IsReply:   0x01,
+                                       ErrorCode: [4]byte{0, 0, 0, 0},
+                                       Fields:    []Field{},
+                               },
+                       },
+               },
+       }
+       for _, tt := range tests {
+               t.Run(tt.name, func(t *testing.T) {
+                       tranAssertEqual(t, tt.wantRes, HandlePostNewsArt(tt.args.cc, &tt.args.t))
                })
        }
 }