]> git.r.bdr.sh - rbdr/mobius/blobdiff - hotline/transaction_handlers_test.go
Update README.md
[rbdr/mobius] / hotline / transaction_handlers_test.go
index 5136c7d314934701bce8cb10938fab9ebb6b1434..b7cc0afbc609ac78dbaeea3506f0029fa57b8bce 100644 (file)
@@ -2,13 +2,14 @@ package hotline
 
 import (
        "errors"
-       "fmt"
        "github.com/stretchr/testify/assert"
+       "github.com/stretchr/testify/mock"
+       "io"
        "io/fs"
-       "math/rand"
        "os"
        "path/filepath"
        "strings"
+       "sync"
        "testing"
        "time"
 )
@@ -16,13 +17,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",
@@ -30,92 +30,74 @@ func TestHandleSetChatSubject(t *testing.T) {
                                cc: &ClientConn{
                                        UserName: []byte{0x00, 0x01},
                                        Server: &Server{
-                                               PrivateChats: map[uint32]*PrivateChat{
-                                                       uint32(1): {
+                                               PrivateChats: map[[4]byte]*PrivateChat{
+                                                       [4]byte{0, 0, 0, 1}: {
                                                                Subject: "unset",
-                                                               ClientConn: map[uint16]*ClientConn{
-                                                                       uint16(1): {
+                                                               ClientConn: map[[2]byte]*ClientConn{
+                                                                       [2]byte{0, 1}: {
                                                                                Account: &Account{
-                                                                                       Access: &[]byte{255, 255, 255, 255, 255, 255, 255, 255},
+                                                                                       Access: accessBitmap{255, 255, 255, 255, 255, 255, 255, 255},
                                                                                },
-                                                                               ID: &[]byte{0, 1},
+                                                                               ID: [2]byte{0, 1},
                                                                        },
-                                                                       uint16(2): {
+                                                                       [2]byte{0, 2}: {
                                                                                Account: &Account{
-                                                                                       Access: &[]byte{255, 255, 255, 255, 255, 255, 255, 255},
+                                                                                       Access: accessBitmap{255, 255, 255, 255, 255, 255, 255, 255},
                                                                                },
-                                                                               ID: &[]byte{0, 2},
+                                                                               ID: [2]byte{0, 2},
                                                                        },
                                                                },
                                                        },
                                                },
-                                               Clients: map[uint16]*ClientConn{
-                                                       uint16(1): {
+                                               Clients: map[[2]byte]*ClientConn{
+                                                       [2]byte{0, 1}: {
                                                                Account: &Account{
-                                                                       Access: &[]byte{255, 255, 255, 255, 255, 255, 255, 255},
+                                                                       Access: accessBitmap{255, 255, 255, 255, 255, 255, 255, 255},
                                                                },
-                                                               ID: &[]byte{0, 1},
+                                                               ID: [2]byte{0, 1},
                                                        },
-                                                       uint16(2): {
+                                                       [2]byte{0, 2}: {
                                                                Account: &Account{
-                                                                       Access: &[]byte{255, 255, 255, 255, 255, 255, 255, 255},
+                                                                       Access: accessBitmap{255, 255, 255, 255, 255, 255, 255, 255},
                                                                },
-                                                               ID: &[]byte{0, 2},
+                                                               ID: [2]byte{0, 2},
                                                        },
                                                },
                                        },
                                },
-                               t: &Transaction{
-                                       Flags:     0x00,
-                                       IsReply:   0x00,
-                                       Type:      []byte{0, 0x6a},
-                                       ID:        []byte{0, 0, 0, 1},
-                                       ErrorCode: []byte{0, 0, 0, 0},
+                               t: Transaction{
+                                       Type: [2]byte{0, 0x6a},
+                                       ID:   [4]byte{0, 0, 0, 1},
                                        Fields: []Field{
-                                               NewField(fieldChatID, []byte{0, 0, 0, 1}),
-                                               NewField(fieldChatSubject, []byte("Test Subject")),
+                                               NewField(FieldChatID, []byte{0, 0, 0, 1}),
+                                               NewField(FieldChatSubject, []byte("Test Subject")),
                                        },
                                },
                        },
                        want: []Transaction{
                                {
-                                       clientID:  &[]byte{0, 1},
-                                       Flags:     0x00,
-                                       IsReply:   0x00,
-                                       Type:      []byte{0, 0x77},
-                                       ID:        []byte{0x9a, 0xcb, 0x04, 0x42}, // Random ID from rand.Seed(1)
-                                       ErrorCode: []byte{0, 0, 0, 0},
+                                       clientID: [2]byte{0, 1},
+                                       Type:     [2]byte{0, 0x77},
                                        Fields: []Field{
-                                               NewField(fieldChatID, []byte{0, 0, 0, 1}),
-                                               NewField(fieldChatSubject, []byte("Test Subject")),
+                                               NewField(FieldChatID, []byte{0, 0, 0, 1}),
+                                               NewField(FieldChatSubject, []byte("Test Subject")),
                                        },
                                },
                                {
-                                       clientID:  &[]byte{0, 2},
-                                       Flags:     0x00,
-                                       IsReply:   0x00,
-                                       Type:      []byte{0, 0x77},
-                                       ID:        []byte{0xf0, 0xc5, 0x34, 0x1e}, // Random ID from rand.Seed(1)
-                                       ErrorCode: []byte{0, 0, 0, 0},
+                                       clientID: [2]byte{0, 2},
+                                       Type:     [2]byte{0, 0x77},
                                        Fields: []Field{
-                                               NewField(fieldChatID, []byte{0, 0, 0, 1}),
-                                               NewField(fieldChatSubject, []byte("Test Subject")),
+                                               NewField(FieldChatID, []byte{0, 0, 0, 1}),
+                                               NewField(FieldChatSubject, []byte("Test Subject")),
                                        },
                                },
                        },
-                       wantErr: false,
                },
        }
        for _, tt := range tests {
-               rand.Seed(1) // reset seed between tests to make transaction IDs predictable
-
                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
-                       }
-                       if !assert.Equal(t, tt.want, got) {
+                       got := HandleSetChatSubject(tt.args.cc, &tt.args.t)
+                       if !tranAssertEqual(t, tt.want, got) {
                                t.Errorf("HandleSetChatSubject() got = %v, want %v", got, tt.want)
                        }
                })
@@ -125,82 +107,71 @@ 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",
                        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): {
+                                               PrivateChats: map[[4]byte]*PrivateChat{
+                                                       [4]byte{0, 0, 0, 1}: {
+                                                               ClientConn: map[[2]byte]*ClientConn{
+                                                                       [2]byte{0, 1}: {
                                                                                Account: &Account{
-                                                                                       Access: &[]byte{255, 255, 255, 255, 255, 255, 255, 255},
+                                                                                       Access: accessBitmap{255, 255, 255, 255, 255, 255, 255, 255},
                                                                                },
-                                                                               ID: &[]byte{0, 1},
+                                                                               ID: [2]byte{0, 1},
                                                                        },
-                                                                       uint16(2): {
+                                                                       [2]byte{0, 2}: {
                                                                                Account: &Account{
-                                                                                       Access: &[]byte{255, 255, 255, 255, 255, 255, 255, 255},
+                                                                                       Access: accessBitmap{255, 255, 255, 255, 255, 255, 255, 255},
                                                                                },
-                                                                               ID: &[]byte{0, 2},
+                                                                               ID: [2]byte{0, 2},
                                                                        },
                                                                },
                                                        },
                                                },
-                                               Clients: map[uint16]*ClientConn{
-                                                       uint16(1): {
+                                               Clients: map[[2]byte]*ClientConn{
+                                                       [2]byte{0, 1}: {
                                                                Account: &Account{
-                                                                       Access: &[]byte{255, 255, 255, 255, 255, 255, 255, 255},
+                                                                       Access: accessBitmap{255, 255, 255, 255, 255, 255, 255, 255},
                                                                },
-                                                               ID: &[]byte{0, 1},
+                                                               ID: [2]byte{0, 1},
                                                        },
-                                                       uint16(2): {
+                                                       [2]byte{0, 2}: {
                                                                Account: &Account{
-                                                                       Access: &[]byte{255, 255, 255, 255, 255, 255, 255, 255},
+                                                                       Access: accessBitmap{255, 255, 255, 255, 255, 255, 255, 255},
                                                                },
-                                                               ID: &[]byte{0, 2},
+                                                               ID: [2]byte{0, 2},
                                                        },
                                                },
                                        },
                                },
-                               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,
-                                       Type:      []byte{0, 0x76},
-                                       ID:        []byte{0x9a, 0xcb, 0x04, 0x42}, // Random ID from rand.Seed(1)
-                                       ErrorCode: []byte{0, 0, 0, 0},
+                                       clientID: [2]byte{0, 1},
+                                       Type:     [2]byte{0, 0x76},
                                        Fields: []Field{
-                                               NewField(fieldChatID, []byte{0, 0, 0, 1}),
-                                               NewField(fieldUserID, []byte{0, 2}),
+                                               NewField(FieldChatID, []byte{0, 0, 0, 1}),
+                                               NewField(FieldUserID, []byte{0, 2}),
                                        },
                                },
                        },
-                       wantErr: false,
                },
        }
        for _, tt := range tests {
-               rand.Seed(1)
                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
-                       }
-                       if !assert.Equal(t, tt.want, got) {
+                       got := HandleLeaveChat(tt.args.cc, &tt.args.t)
+                       if !tranAssertEqual(t, tt.want, got) {
                                t.Errorf("HandleLeaveChat() got = %v, want %v", got, tt.want)
                        }
                })
@@ -210,81 +181,58 @@ 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},
-                                                               Agreed:   true,
-                                                       },
-                                                       uint16(2): {
-                                                               ID:       &[]byte{0, 2},
-                                                               Icon:     &[]byte{0, 2},
-                                                               Flags:    &[]byte{0, 3},
+                                               Clients: map[[2]byte]*ClientConn{
+                                                       [2]byte{0, 1}: {
+                                                               ID:       [2]byte{0, 1},
+                                                               Icon:     []byte{0, 2},
+                                                               Flags:    [2]byte{0, 3},
                                                                UserName: []byte{0, 4},
-                                                               Agreed:   true,
                                                        },
-                                                       uint16(3): {
-                                                               ID:       &[]byte{0, 3},
-                                                               Icon:     &[]byte{0, 2},
-                                                               Flags:    &[]byte{0, 3},
+                                                       [2]byte{0, 2}: {
+                                                               ID:       [2]byte{0, 2},
+                                                               Icon:     []byte{0, 2},
+                                                               Flags:    [2]byte{0, 3},
                                                                UserName: []byte{0, 4},
-                                                               Agreed:   false,
                                                        },
                                                },
                                        },
                                },
-                               t: &Transaction{
-                                       ID:   []byte{0, 0, 0, 1},
-                                       Type: []byte{0, 1},
-                               },
+                               t: Transaction{},
                        },
                        want: []Transaction{
                                {
-                                       clientID:  &[]byte{1, 1},
-                                       Flags:     0x00,
-                                       IsReply:   0x01,
-                                       Type:      []byte{0, 1},
-                                       ID:        []byte{0, 0, 0, 1},
-                                       ErrorCode: []byte{0, 0, 0, 0},
+                                       clientID: [2]byte{0, 1},
+                                       IsReply:  0x01,
                                        Fields: []Field{
                                                NewField(
-                                                       fieldUsernameWithInfo,
+                                                       FieldUsernameWithInfo,
                                                        []byte{00, 01, 00, 02, 00, 03, 00, 02, 00, 04},
                                                ),
                                                NewField(
-                                                       fieldUsernameWithInfo,
+                                                       FieldUsernameWithInfo,
                                                        []byte{00, 02, 00, 02, 00, 03, 00, 02, 00, 04},
                                                ),
                                        },
                                },
                        },
-                       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)
                })
        }
@@ -293,85 +241,130 @@ 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",
                        args: args{
                                cc: &ClientConn{
                                        Account: &Account{
-                                               Access: func() *[]byte {
+                                               Access: func() accessBitmap {
                                                        var bits accessBitmap
                                                        bits.Set(accessSendChat)
-                                                       access := bits[:]
-                                                       return &access
+                                                       return bits
                                                }(),
                                        },
                                        UserName: []byte{0x00, 0x01},
                                        Server: &Server{
-                                               Clients: map[uint16]*ClientConn{
-                                                       uint16(1): {
+                                               Clients: map[[2]byte]*ClientConn{
+                                                       [2]byte{0, 1}: {
                                                                Account: &Account{
-                                                                       Access: &[]byte{255, 255, 255, 255, 255, 255, 255, 255},
+                                                                       Access: accessBitmap{255, 255, 255, 255, 255, 255, 255, 255},
                                                                },
-                                                               ID: &[]byte{0, 1},
+                                                               ID: [2]byte{0, 1},
                                                        },
-                                                       uint16(2): {
+                                                       [2]byte{0, 2}: {
                                                                Account: &Account{
-                                                                       Access: &[]byte{255, 255, 255, 255, 255, 255, 255, 255},
+                                                                       Access: accessBitmap{255, 255, 255, 255, 255, 255, 255, 255},
                                                                },
-                                                               ID: &[]byte{0, 2},
+                                                               ID: [2]byte{0, 2},
                                                        },
                                                },
                                        },
                                },
-                               t: &Transaction{
+                               t: Transaction{
                                        Fields: []Field{
-                                               NewField(fieldData, []byte("hai")),
+                                               NewField(FieldData, []byte("hai")),
                                        },
                                },
                        },
                        want: []Transaction{
                                {
-                                       clientID:  &[]byte{0, 1},
-                                       Flags:     0x00,
-                                       IsReply:   0x00,
-                                       Type:      []byte{0, 0x6a},
-                                       ID:        []byte{0x9a, 0xcb, 0x04, 0x42}, // Random ID from rand.Seed(1)
-                                       ErrorCode: []byte{0, 0, 0, 0},
+                                       clientID: [2]byte{0, 1},
+                                       Flags:    0x00,
+                                       IsReply:  0x00,
+                                       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}),
+                                               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},
-                                       Flags:     0x00,
-                                       IsReply:   0x00,
-                                       Type:      []byte{0, 0x6a},
-                                       ID:        []byte{0xf0, 0xc5, 0x34, 0x1e}, // Random ID from rand.Seed(1)
-                                       ErrorCode: []byte{0, 0, 0, 0},
+                                       clientID: [2]byte{0, 2},
+                                       Flags:    0x00,
+                                       IsReply:  0x00,
+                                       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}),
+                                       },
+                               },
+                       },
+               },
+               {
+                       name: "treats Chat ID 00 00 00 00 as a public chat message",
+                       args: args{
+                               cc: &ClientConn{
+                                       Account: &Account{
+                                               Access: func() accessBitmap {
+                                                       var bits accessBitmap
+                                                       bits.Set(accessSendChat)
+                                                       return bits
+                                               }(),
+                                       },
+                                       UserName: []byte{0x00, 0x01},
+                                       Server: &Server{
+                                               Clients: 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},
+                                                       },
+                                               },
+                                       },
+                               },
+                               t: Transaction{
                                        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}),
+                                               NewField(FieldData, []byte("hai")),
+                                               NewField(FieldChatID, []byte{0, 0, 0, 0}),
+                                       },
+                               },
+                       },
+                       want: []Transaction{
+                               {
+                                       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: [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",
                        args: args{
                                cc: &ClientConn{
                                        Account: &Account{
-                                               Access: func() *[]byte {
+                                               Access: func() accessBitmap {
                                                        var bits accessBitmap
-                                                       access := bits[:]
-                                                       return &access
+                                                       return bits
                                                }(),
                                        },
                                        Server: &Server{
@@ -379,253 +372,275 @@ func TestHandleChatSend(t *testing.T) {
                                        },
                                },
                                t: NewTransaction(
-                                       tranChatSend, &[]byte{0, 1},
-                                       NewField(fieldData, []byte("hai")),
+                                       TranChatSend, [2]byte{0, 1},
+                                       NewField(FieldData, []byte("hai")),
                                ),
                        },
                        want: []Transaction{
                                {
-                                       Flags:     0x00,
                                        IsReply:   0x01,
-                                       Type:      []byte{0, 0x00},
-                                       ID:        []byte{0x9a, 0xcb, 0x04, 0x42},
-                                       ErrorCode: []byte{0, 0, 0, 1},
+                                       ErrorCode: [4]byte{0, 0, 0, 1},
                                        Fields: []Field{
-                                               NewField(fieldError, []byte("You are not allowed to participate in chat.")),
+                                               NewField(FieldError, []byte("You are not allowed to participate in chat.")),
                                        },
                                },
                        },
-                       wantErr: false,
                },
                {
-                       name: "sends chat msg as emote if fieldChatOptions is set",
+                       name: "sends chat msg as emote if FieldChatOptions is set to 1",
                        args: args{
                                cc: &ClientConn{
                                        Account: &Account{
-                                               Access: func() *[]byte {
+                                               Access: func() accessBitmap {
                                                        var bits accessBitmap
                                                        bits.Set(accessSendChat)
-                                                       access := bits[:]
-                                                       return &access
+                                                       return bits
                                                }(),
                                        },
                                        UserName: []byte("Testy McTest"),
                                        Server: &Server{
-                                               Clients: map[uint16]*ClientConn{
-                                                       uint16(1): {
+                                               Clients: map[[2]byte]*ClientConn{
+                                                       [2]byte{0, 1}: {
                                                                Account: &Account{
-                                                                       Access: &[]byte{255, 255, 255, 255, 255, 255, 255, 255},
+                                                                       Access: accessBitmap{255, 255, 255, 255, 255, 255, 255, 255},
                                                                },
-                                                               ID: &[]byte{0, 1},
+                                                               ID: [2]byte{0, 1},
                                                        },
-                                                       uint16(2): {
+                                                       [2]byte{0, 2}: {
                                                                Account: &Account{
-                                                                       Access: &[]byte{255, 255, 255, 255, 255, 255, 255, 255},
+                                                                       Access: accessBitmap{255, 255, 255, 255, 255, 255, 255, 255},
                                                                },
-                                                               ID: &[]byte{0, 2},
+                                                               ID: [2]byte{0, 2},
                                                        },
                                                },
                                        },
                                },
-                               t: &Transaction{
+                               t: Transaction{
                                        Fields: []Field{
-                                               NewField(fieldData, []byte("performed action")),
-                                               NewField(fieldChatOptions, []byte{0x00, 0x01}),
+                                               NewField(FieldData, []byte("performed action")),
+                                               NewField(FieldChatOptions, []byte{0x00, 0x01}),
                                        },
                                },
                        },
                        want: []Transaction{
                                {
-                                       clientID:  &[]byte{0, 1},
-                                       Flags:     0x00,
-                                       IsReply:   0x00,
-                                       Type:      []byte{0, 0x6a},
-                                       ID:        []byte{0x9a, 0xcb, 0x04, 0x42},
-                                       ErrorCode: []byte{0, 0, 0, 0},
+                                       clientID: [2]byte{0, 1},
+                                       Flags:    0x00,
+                                       IsReply:  0x00,
+                                       Type:     [2]byte{0, 0x6a},
                                        Fields: []Field{
-                                               NewField(fieldData, []byte("\r*** Testy McTest performed action")),
+                                               NewField(FieldData, []byte("\r*** Testy McTest performed action")),
                                        },
                                },
                                {
-                                       clientID:  &[]byte{0, 2},
-                                       Flags:     0x00,
-                                       IsReply:   0x00,
-                                       Type:      []byte{0, 0x6a},
-                                       ID:        []byte{0xf0, 0xc5, 0x34, 0x1e},
-                                       ErrorCode: []byte{0, 0, 0, 0},
+                                       clientID: [2]byte{0, 2},
+                                       Flags:    0x00,
+                                       IsReply:  0x00,
+                                       Type:     [2]byte{0, 0x6a},
+                                       Fields: []Field{
+                                               NewField(FieldData, []byte("\r*** Testy McTest performed action")),
+                                       },
+                               },
+                       },
+               },
+               {
+                       name: "does not send chat msg as emote if FieldChatOptions is set to 0",
+                       args: args{
+                               cc: &ClientConn{
+                                       Account: &Account{
+                                               Access: func() accessBitmap {
+                                                       var bits accessBitmap
+                                                       bits.Set(accessSendChat)
+                                                       return bits
+                                               }(),
+                                       },
+                                       UserName: []byte("Testy McTest"),
+                                       Server: &Server{
+                                               Clients: 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},
+                                                       },
+                                               },
+                                       },
+                               },
+                               t: Transaction{
+                                       Fields: []Field{
+                                               NewField(FieldData, []byte("hello")),
+                                               NewField(FieldChatOptions, []byte{0x00, 0x00}),
+                                       },
+                               },
+                       },
+                       want: []Transaction{
+                               {
+                                       clientID: [2]byte{0, 1},
+                                       Type:     [2]byte{0, 0x6a},
+                                       Fields: []Field{
+                                               NewField(FieldData, []byte("\r Testy McTest:  hello")),
+                                       },
+                               },
+                               {
+                                       clientID: [2]byte{0, 2},
+                                       Type:     [2]byte{0, 0x6a},
                                        Fields: []Field{
-                                               NewField(fieldData, []byte("\r*** Testy McTest performed action")),
+                                               NewField(FieldData, []byte("\r Testy McTest:  hello")),
                                        },
                                },
                        },
-                       wantErr: false,
                },
                {
                        name: "only sends chat msg to clients with accessReadChat permission",
                        args: args{
                                cc: &ClientConn{
                                        Account: &Account{
-                                               Access: func() *[]byte {
+                                               Access: func() accessBitmap {
                                                        var bits accessBitmap
                                                        bits.Set(accessSendChat)
-                                                       access := bits[:]
-                                                       return &access
+                                                       return bits
                                                }(),
                                        },
                                        UserName: []byte{0x00, 0x01},
                                        Server: &Server{
-                                               Clients: map[uint16]*ClientConn{
-                                                       uint16(1): {
+                                               Clients: map[[2]byte]*ClientConn{
+                                                       [2]byte{0, 1}: {
                                                                Account: &Account{
-                                                                       Access: &[]byte{255, 255, 255, 255, 255, 255, 255, 255},
-                                                               },
-                                                               ID: &[]byte{0, 1},
+                                                                       Access: func() accessBitmap {
+                                                                               var bits accessBitmap
+                                                                               bits.Set(accessReadChat)
+                                                                               return bits
+                                                                       }()},
+                                                               ID: [2]byte{0, 1},
                                                        },
-                                                       uint16(2): {
+                                                       [2]byte{0, 2}: {
                                                                Account: &Account{
-                                                                       Access: &[]byte{0, 0, 0, 0, 0, 0, 0, 0},
+                                                                       Access: accessBitmap{0, 0, 0, 0, 0, 0, 0, 0},
                                                                },
-                                                               ID: &[]byte{0, 2},
+                                                               ID: [2]byte{0, 2},
                                                        },
                                                },
                                        },
                                },
-                               t: &Transaction{
+                               t: Transaction{
                                        Fields: []Field{
-                                               NewField(fieldData, []byte("hai")),
+                                               NewField(FieldData, []byte("hai")),
                                        },
                                },
                        },
                        want: []Transaction{
                                {
-                                       clientID:  &[]byte{0, 1},
-                                       Flags:     0x00,
-                                       IsReply:   0x00,
-                                       Type:      []byte{0, 0x6a},
-                                       ID:        []byte{0x9a, 0xcb, 0x04, 0x42}, // Random ID from rand.Seed(1)
-                                       ErrorCode: []byte{0, 0, 0, 0},
+                                       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}),
+                                               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",
                        args: args{
                                cc: &ClientConn{
                                        Account: &Account{
-                                               Access: func() *[]byte {
+                                               Access: func() accessBitmap {
                                                        var bits accessBitmap
                                                        bits.Set(accessSendChat)
-                                                       access := bits[:]
-                                                       return &access
+                                                       return bits
                                                }(),
                                        },
                                        UserName: []byte{0x00, 0x01},
                                        Server: &Server{
-                                               PrivateChats: map[uint32]*PrivateChat{
-                                                       uint32(1): {
-                                                               ClientConn: map[uint16]*ClientConn{
-                                                                       uint16(1): {
-                                                                               ID: &[]byte{0, 1},
+                                               PrivateChats: map[[4]byte]*PrivateChat{
+                                                       [4]byte{0, 0, 0, 1}: {
+                                                               ClientConn: map[[2]byte]*ClientConn{
+                                                                       [2]byte{0, 1}: {
+                                                                               ID: [2]byte{0, 1},
                                                                        },
-                                                                       uint16(2): {
-                                                                               ID: &[]byte{0, 2},
+                                                                       [2]byte{0, 2}: {
+                                                                               ID: [2]byte{0, 2},
                                                                        },
                                                                },
                                                        },
                                                },
-                                               Clients: map[uint16]*ClientConn{
-                                                       uint16(1): {
+                                               Clients: map[[2]byte]*ClientConn{
+                                                       [2]byte{0, 1}: {
                                                                Account: &Account{
-                                                                       Access: &[]byte{255, 255, 255, 255, 255, 255, 255, 255},
+                                                                       Access: accessBitmap{255, 255, 255, 255, 255, 255, 255, 255},
                                                                },
-                                                               ID: &[]byte{0, 1},
+                                                               ID: [2]byte{0, 1},
                                                        },
-                                                       uint16(2): {
+                                                       [2]byte{0, 2}: {
                                                                Account: &Account{
-                                                                       Access: &[]byte{0, 0, 0, 0, 0, 0, 0, 0},
+                                                                       Access: accessBitmap{0, 0, 0, 0, 0, 0, 0, 0},
                                                                },
-                                                               ID: &[]byte{0, 2},
+                                                               ID: [2]byte{0, 2},
                                                        },
-                                                       uint16(3): {
+                                                       [2]byte{0, 3}: {
                                                                Account: &Account{
-                                                                       Access: &[]byte{0, 0, 0, 0, 0, 0, 0, 0},
+                                                                       Access: accessBitmap{0, 0, 0, 0, 0, 0, 0, 0},
                                                                },
-                                                               ID: &[]byte{0, 3},
+                                                               ID: [2]byte{0, 3},
                                                        },
                                                },
                                        },
                                },
-                               t: &Transaction{
+                               t: Transaction{
                                        Fields: []Field{
-                                               NewField(fieldData, []byte("hai")),
-                                               NewField(fieldChatID, []byte{0, 0, 0, 1}),
+                                               NewField(FieldData, []byte("hai")),
+                                               NewField(FieldChatID, []byte{0, 0, 0, 1}),
                                        },
                                },
                        },
                        want: []Transaction{
                                {
-                                       clientID:  &[]byte{0, 1},
-                                       Flags:     0x00,
-                                       IsReply:   0x00,
-                                       Type:      []byte{0, 0x6a},
-                                       ID:        []byte{0x9a, 0xcb, 0x04, 0x42},
-                                       ErrorCode: []byte{0, 0, 0, 0},
+                                       clientID: [2]byte{0, 1},
+                                       Type:     [2]byte{0, 0x6a},
                                        Fields: []Field{
-                                               NewField(fieldChatID, []byte{0, 0, 0, 1}),
-                                               NewField(fieldData, []byte{0x0d, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x00, 0x01, 0x3a, 0x20, 0x20, 0x68, 0x61, 0x69}),
+                                               NewField(FieldChatID, []byte{0, 0, 0, 1}),
+                                               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},
-                                       Flags:     0x00,
-                                       IsReply:   0x00,
-                                       Type:      []byte{0, 0x6a},
-                                       ID:        []byte{0x9a, 0xcb, 0x04, 0x42},
-                                       ErrorCode: []byte{0, 0, 0, 0},
+                                       clientID: [2]byte{0, 2},
+                                       Type:     [2]byte{0, 0x6a},
                                        Fields: []Field{
-                                               NewField(fieldChatID, []byte{0, 0, 0, 1}),
-                                               NewField(fieldData, []byte{0x0d, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x00, 0x01, 0x3a, 0x20, 0x20, 0x68, 0x61, 0x69}),
+                                               NewField(FieldChatID, []byte{0, 0, 0, 1}),
+                                               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,
                },
        }
        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)
                })
        }
 }
 
 func TestHandleGetFileInfo(t *testing.T) {
-       rand.Seed(1) // reset seed between tests to make transaction IDs predictable
-
        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{
@@ -637,49 +652,39 @@ func TestHandleGetFileInfo(t *testing.T) {
                                        },
                                },
                                t: NewTransaction(
-                                       tranGetFileInfo, nil,
-                                       NewField(fieldFileName, []byte("testfile.txt")),
-                                       NewField(fieldFilePath, []byte{0x00, 0x00}),
+                                       TranGetFileInfo, [2]byte{},
+                                       NewField(FieldFileName, []byte("testfile.txt")),
+                                       NewField(FieldFilePath, []byte{0x00, 0x00}),
                                ),
                        },
                        wantRes: []Transaction{
                                {
-                                       clientID:  &[]byte{0, 1},
-                                       Flags:     0x00,
-                                       IsReply:   0x01,
-                                       Type:      []byte{0, 0xce},
-                                       ID:        []byte{0x9a, 0xcb, 0x04, 0x42}, // Random ID from rand.Seed(1)
-                                       ErrorCode: []byte{0, 0, 0, 0},
+                                       clientID: [2]byte{0, 1},
+                                       IsReply:  0x01,
+                                       Type:     [2]byte{0, 0},
                                        Fields: []Field{
-                                               NewField(fieldFileName, []byte("testfile.txt")),
-                                               NewField(fieldFileTypeString, []byte("Text File")),
-                                               NewField(fieldFileCreatorString, []byte("ttxt")),
-                                               NewField(fieldFileComment, []byte{}),
-                                               NewField(fieldFileType, []byte("TEXT")),
-                                               NewField(fieldFileCreateDate, make([]byte, 8)),
-                                               NewField(fieldFileModifyDate, make([]byte, 8)),
-                                               NewField(fieldFileSize, []byte{0x0, 0x0, 0x0, 0x17}),
+                                               NewField(FieldFileName, []byte("testfile.txt")),
+                                               NewField(FieldFileTypeString, []byte("Text File")),
+                                               NewField(FieldFileCreatorString, []byte("ttxt")),
+                                               NewField(FieldFileType, []byte("TEXT")),
+                                               NewField(FieldFileCreateDate, make([]byte, 8)),
+                                               NewField(FieldFileModifyDate, make([]byte, 8)),
+                                               NewField(FieldFileSize, []byte{0x0, 0x0, 0x0, 0x17}),
                                        },
                                },
                        },
-                       wantErr: false,
                },
        }
        for _, tt := range tests {
                t.Run(tt.name, func(t *testing.T) {
-                       rand.Seed(1) // reset seed between tests to make transaction IDs predictable
-
-                       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)
-                       gotRes[0].Fields[6].Data = make([]byte, 8)
-                       if !assert.Equal(t, tt.wantRes, gotRes) {
+
+                       if !tranAssertEqual(t, tt.wantRes, gotRes) {
                                t.Errorf("HandleGetFileInfo() gotRes = %v, want %v", gotRes, tt.wantRes)
                        }
                })
@@ -689,58 +694,51 @@ 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",
                        args: args{
                                cc: &ClientConn{
                                        Account: &Account{
-                                               Access: func() *[]byte {
+                                               Access: func() accessBitmap {
                                                        var bits accessBitmap
-                                                       access := bits[:]
-                                                       return &access
+                                                       return bits
                                                }(),
                                        },
                                },
                                t: NewTransaction(
-                                       accessCreateFolder,
-                                       &[]byte{0, 0},
+                                       TranNewFolder,
+                                       [2]byte{0, 0},
                                ),
                        },
                        wantRes: []Transaction{
                                {
-                                       Flags:     0x00,
                                        IsReply:   0x01,
-                                       Type:      []byte{0, 0x00},
-                                       ID:        []byte{0x9a, 0xcb, 0x04, 0x42},
-                                       ErrorCode: []byte{0, 0, 0, 1},
+                                       ErrorCode: [4]byte{0, 0, 0, 1},
                                        Fields: []Field{
-                                               NewField(fieldError, []byte("You are not allowed to create folders.")),
+                                               NewField(FieldError, []byte("You are not allowed to create folders.")),
                                        },
                                },
                        },
-                       wantErr: false,
                },
                {
                        name: "when path is nested",
                        args: args{
                                cc: &ClientConn{
                                        Account: &Account{
-                                               Access: func() *[]byte {
+                                               Access: func() accessBitmap {
                                                        var bits accessBitmap
                                                        bits.Set(accessCreateFolder)
-                                                       access := bits[:]
-                                                       return &access
+                                                       return bits
                                                }(),
                                        },
-                                       ID: &[]byte{0, 1},
+                                       ID: [2]byte{0, 1},
                                        Server: &Server{
                                                Config: &Config{
                                                        FileRoot: "/Files/",
@@ -754,9 +752,9 @@ func TestHandleNewFolder(t *testing.T) {
                                        },
                                },
                                t: NewTransaction(
-                                       tranNewFolder, &[]byte{0, 1},
-                                       NewField(fieldFileName, []byte("testFolder")),
-                                       NewField(fieldFilePath, []byte{
+                                       TranNewFolder, [2]byte{0, 1},
+                                       NewField(FieldFileName, []byte("testFolder")),
+                                       NewField(FieldFilePath, []byte{
                                                0x00, 0x01,
                                                0x00, 0x00,
                                                0x03,
@@ -766,29 +764,23 @@ func TestHandleNewFolder(t *testing.T) {
                        },
                        wantRes: []Transaction{
                                {
-                                       clientID:  &[]byte{0, 1},
-                                       Flags:     0x00,
-                                       IsReply:   0x01,
-                                       Type:      []byte{0, 0xcd},
-                                       ID:        []byte{0x9a, 0xcb, 0x04, 0x42}, // Random ID from rand.Seed(1)
-                                       ErrorCode: []byte{0, 0, 0, 0},
+                                       clientID: [2]byte{0, 1},
+                                       IsReply:  0x01,
                                },
                        },
-                       wantErr: false,
                },
                {
                        name: "when path is not nested",
                        args: args{
                                cc: &ClientConn{
                                        Account: &Account{
-                                               Access: func() *[]byte {
+                                               Access: func() accessBitmap {
                                                        var bits accessBitmap
                                                        bits.Set(accessCreateFolder)
-                                                       access := bits[:]
-                                                       return &access
+                                                       return bits
                                                }(),
                                        },
-                                       ID: &[]byte{0, 1},
+                                       ID: [2]byte{0, 1},
                                        Server: &Server{
                                                Config: &Config{
                                                        FileRoot: "/Files",
@@ -802,35 +794,29 @@ func TestHandleNewFolder(t *testing.T) {
                                        },
                                },
                                t: NewTransaction(
-                                       tranNewFolder, &[]byte{0, 1},
-                                       NewField(fieldFileName, []byte("testFolder")),
+                                       TranNewFolder, [2]byte{0, 1},
+                                       NewField(FieldFileName, []byte("testFolder")),
                                ),
                        },
                        wantRes: []Transaction{
                                {
-                                       clientID:  &[]byte{0, 1},
-                                       Flags:     0x00,
-                                       IsReply:   0x01,
-                                       Type:      []byte{0, 0xcd},
-                                       ID:        []byte{0x9a, 0xcb, 0x04, 0x42}, // Random ID from rand.Seed(1)
-                                       ErrorCode: []byte{0, 0, 0, 0},
+                                       clientID: [2]byte{0, 1},
+                                       IsReply:  0x01,
                                },
                        },
-                       wantErr: false,
                },
                {
-                       name: "when UnmarshalBinary returns an err",
+                       name: "when Write returns an err",
                        args: args{
                                cc: &ClientConn{
                                        Account: &Account{
-                                               Access: func() *[]byte {
+                                               Access: func() accessBitmap {
                                                        var bits accessBitmap
                                                        bits.Set(accessCreateFolder)
-                                                       access := bits[:]
-                                                       return &access
+                                                       return bits
                                                }(),
                                        },
-                                       ID: &[]byte{0, 1},
+                                       ID: [2]byte{0, 1},
                                        Server: &Server{
                                                Config: &Config{
                                                        FileRoot: "/Files/",
@@ -844,29 +830,27 @@ func TestHandleNewFolder(t *testing.T) {
                                        },
                                },
                                t: NewTransaction(
-                                       tranNewFolder, &[]byte{0, 1},
-                                       NewField(fieldFileName, []byte("testFolder")),
-                                       NewField(fieldFilePath, []byte{
+                                       TranNewFolder, [2]byte{0, 1},
+                                       NewField(FieldFileName, []byte("testFolder")),
+                                       NewField(FieldFilePath, []byte{
                                                0x00,
                                        }),
                                ),
                        },
                        wantRes: []Transaction{},
-                       wantErr: true,
                },
                {
-                       name: "fieldFileName does not allow directory traversal",
+                       name: "FieldFileName does not allow directory traversal",
                        args: args{
                                cc: &ClientConn{
                                        Account: &Account{
-                                               Access: func() *[]byte {
+                                               Access: func() accessBitmap {
                                                        var bits accessBitmap
                                                        bits.Set(accessCreateFolder)
-                                                       access := bits[:]
-                                                       return &access
+                                                       return bits
                                                }(),
                                        },
-                                       ID: &[]byte{0, 1},
+                                       ID: [2]byte{0, 1},
                                        Server: &Server{
                                                Config: &Config{
                                                        FileRoot: "/Files/",
@@ -880,34 +864,29 @@ func TestHandleNewFolder(t *testing.T) {
                                        },
                                },
                                t: NewTransaction(
-                                       tranNewFolder, &[]byte{0, 1},
-                                       NewField(fieldFileName, []byte("../../testFolder")),
+                                       TranNewFolder, [2]byte{0, 1},
+                                       NewField(FieldFileName, []byte("../../testFolder")),
                                ),
                        },
                        wantRes: []Transaction{
                                {
-                                       clientID:  &[]byte{0, 1},
-                                       Flags:     0x00,
-                                       IsReply:   0x01,
-                                       Type:      []byte{0, 0xcd},
-                                       ID:        []byte{0x9a, 0xcb, 0x04, 0x42}, // Random ID from rand.Seed(1)
-                                       ErrorCode: []byte{0, 0, 0, 0},
+                                       clientID: [2]byte{0, 1},
+                                       IsReply:  0x01,
                                },
-                       }, wantErr: false,
+                       },
                },
                {
-                       name: "fieldFilePath does not allow directory traversal",
+                       name: "FieldFilePath does not allow directory traversal",
                        args: args{
                                cc: &ClientConn{
                                        Account: &Account{
-                                               Access: func() *[]byte {
+                                               Access: func() accessBitmap {
                                                        var bits accessBitmap
                                                        bits.Set(accessCreateFolder)
-                                                       access := bits[:]
-                                                       return &access
+                                                       return bits
                                                }(),
                                        },
-                                       ID: &[]byte{0, 1},
+                                       ID: [2]byte{0, 1},
                                        Server: &Server{
                                                Config: &Config{
                                                        FileRoot: "/Files/",
@@ -921,9 +900,9 @@ func TestHandleNewFolder(t *testing.T) {
                                        },
                                },
                                t: NewTransaction(
-                                       tranNewFolder, &[]byte{0, 1},
-                                       NewField(fieldFileName, []byte("testFolder")),
-                                       NewField(fieldFilePath, []byte{
+                                       TranNewFolder, [2]byte{0, 1},
+                                       NewField(FieldFileName, []byte("testFolder")),
+                                       NewField(FieldFilePath, []byte{
                                                0x00, 0x02,
                                                0x00, 0x00,
                                                0x03,
@@ -936,24 +915,15 @@ func TestHandleNewFolder(t *testing.T) {
                        },
                        wantRes: []Transaction{
                                {
-                                       clientID:  &[]byte{0, 1},
-                                       Flags:     0x00,
-                                       IsReply:   0x01,
-                                       Type:      []byte{0, 0xcd},
-                                       ID:        []byte{0x9a, 0xcb, 0x04, 0x42}, // Random ID from rand.Seed(1)
-                                       ErrorCode: []byte{0, 0, 0, 0},
+                                       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)
@@ -965,13 +935,12 @@ 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",
@@ -987,19 +956,18 @@ func TestHandleUploadFile(t *testing.T) {
                                                FileUpload: {},
                                        },
                                        Account: &Account{
-                                               Access: func() *[]byte {
+                                               Access: func() accessBitmap {
                                                        var bits accessBitmap
                                                        bits.Set(accessUploadFile)
                                                        bits.Set(accessUploadAnywhere)
-                                                       access := bits[:]
-                                                       return &access
+                                                       return bits
                                                }(),
                                        },
                                },
                                t: NewTransaction(
-                                       tranUploadFile, &[]byte{0, 1},
-                                       NewField(fieldFileName, []byte("testFile")),
-                                       NewField(fieldFilePath, []byte{
+                                       TranUploadFile, [2]byte{0, 1},
+                                       NewField(FieldFileName, []byte("testFile")),
+                                       NewField(FieldFilePath, []byte{
                                                0x00, 0x01,
                                                0x00, 0x00,
                                                0x03,
@@ -1009,34 +977,28 @@ func TestHandleUploadFile(t *testing.T) {
                        },
                        wantRes: []Transaction{
                                {
-                                       Flags:     0x00,
-                                       IsReply:   0x01,
-                                       Type:      []byte{0, 0xcb},
-                                       ID:        []byte{0x9a, 0xcb, 0x04, 0x42},
-                                       ErrorCode: []byte{0, 0, 0, 0},
+                                       IsReply: 0x01,
                                        Fields: []Field{
-                                               NewField(fieldRefNum, []byte{0x52, 0xfd, 0xfc, 0x07}), // rand.Seed(1)
+                                               NewField(FieldRefNum, []byte{0x52, 0xfd, 0xfc, 0x07}), // rand.Seed(1)
                                        },
                                },
                        },
-                       wantErr: false,
                },
                {
                        name: "when user does not have required access",
                        args: args{
                                cc: &ClientConn{
                                        Account: &Account{
-                                               Access: func() *[]byte {
+                                               Access: func() accessBitmap {
                                                        var bits accessBitmap
-                                                       access := bits[:]
-                                                       return &access
+                                                       return bits
                                                }(),
                                        },
                                },
                                t: NewTransaction(
-                                       tranUploadFile, &[]byte{0, 1},
-                                       NewField(fieldFileName, []byte("testFile")),
-                                       NewField(fieldFilePath, []byte{
+                                       TranUploadFile, [2]byte{0, 1},
+                                       NewField(FieldFileName, []byte("testFile")),
+                                       NewField(FieldFilePath, []byte{
                                                0x00, 0x01,
                                                0x00, 0x00,
                                                0x03,
@@ -1046,30 +1008,19 @@ func TestHandleUploadFile(t *testing.T) {
                        },
                        wantRes: []Transaction{
                                {
-                                       Flags:     0x00,
                                        IsReply:   0x01,
-                                       Type:      []byte{0, 0x00},
-                                       ID:        []byte{0x9a, 0xcb, 0x04, 0x42},
-                                       ErrorCode: []byte{0, 0, 0, 1},
+                                       ErrorCode: [4]byte{0, 0, 0, 1},
                                        Fields: []Field{
-                                               NewField(fieldError, []byte("You are not allowed to upload files.")), // rand.Seed(1)
+                                               NewField(FieldError, []byte("You are not allowed to upload files.")), // rand.Seed(1)
                                        },
                                },
                        },
-                       wantErr: false,
                },
        }
        for _, tt := range tests {
                t.Run(tt.name, func(t *testing.T) {
-                       rand.Seed(1)
-                       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)
-
                })
        }
 }
@@ -1077,13 +1028,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",
@@ -1091,11 +1041,10 @@ func TestHandleMakeAlias(t *testing.T) {
                                cc: &ClientConn{
                                        logger: NewTestLogger(),
                                        Account: &Account{
-                                               Access: func() *[]byte {
+                                               Access: func() accessBitmap {
                                                        var bits accessBitmap
                                                        bits.Set(accessMakeAlias)
-                                                       access := bits[:]
-                                                       return &access
+                                                       return bits
                                                }(),
                                        },
                                        Server: &Server{
@@ -1119,23 +1068,18 @@ func TestHandleMakeAlias(t *testing.T) {
                                        },
                                },
                                t: NewTransaction(
-                                       tranMakeFileAlias, &[]byte{0, 1},
-                                       NewField(fieldFileName, []byte("testFile")),
-                                       NewField(fieldFilePath, EncodeFilePath(strings.Join([]string{"foo"}, "/"))),
-                                       NewField(fieldFileNewPath, EncodeFilePath(strings.Join([]string{"bar"}, "/"))),
+                                       TranMakeFileAlias, [2]byte{0, 1},
+                                       NewField(FieldFileName, []byte("testFile")),
+                                       NewField(FieldFilePath, EncodeFilePath(strings.Join([]string{"foo"}, "/"))),
+                                       NewField(FieldFileNewPath, EncodeFilePath(strings.Join([]string{"bar"}, "/"))),
                                ),
                        },
                        wantRes: []Transaction{
                                {
-                                       Flags:     0x00,
-                                       IsReply:   0x01,
-                                       Type:      []byte{0, 0xd1},
-                                       ID:        []byte{0x9a, 0xcb, 0x04, 0x42},
-                                       ErrorCode: []byte{0, 0, 0, 0},
-                                       Fields:    []Field(nil),
+                                       IsReply: 0x01,
+                                       Fields:  []Field(nil),
                                },
                        },
-                       wantErr: false,
                },
                {
                        name: "when symlink returns an error",
@@ -1143,11 +1087,10 @@ func TestHandleMakeAlias(t *testing.T) {
                                cc: &ClientConn{
                                        logger: NewTestLogger(),
                                        Account: &Account{
-                                               Access: func() *[]byte {
+                                               Access: func() accessBitmap {
                                                        var bits accessBitmap
                                                        bits.Set(accessMakeAlias)
-                                                       access := bits[:]
-                                                       return &access
+                                                       return bits
                                                }(),
                                        },
                                        Server: &Server{
@@ -1171,25 +1114,21 @@ func TestHandleMakeAlias(t *testing.T) {
                                        },
                                },
                                t: NewTransaction(
-                                       tranMakeFileAlias, &[]byte{0, 1},
-                                       NewField(fieldFileName, []byte("testFile")),
-                                       NewField(fieldFilePath, EncodeFilePath(strings.Join([]string{"foo"}, "/"))),
-                                       NewField(fieldFileNewPath, EncodeFilePath(strings.Join([]string{"bar"}, "/"))),
+                                       TranMakeFileAlias, [2]byte{0, 1},
+                                       NewField(FieldFileName, []byte("testFile")),
+                                       NewField(FieldFilePath, EncodeFilePath(strings.Join([]string{"foo"}, "/"))),
+                                       NewField(FieldFileNewPath, EncodeFilePath(strings.Join([]string{"bar"}, "/"))),
                                ),
                        },
                        wantRes: []Transaction{
                                {
-                                       Flags:     0x00,
                                        IsReply:   0x01,
-                                       Type:      []byte{0, 0x00},
-                                       ID:        []byte{0x9a, 0xcb, 0x04, 0x42},
-                                       ErrorCode: []byte{0, 0, 0, 1},
+                                       ErrorCode: [4]byte{0, 0, 0, 1},
                                        Fields: []Field{
-                                               NewField(fieldError, []byte("Error creating alias")),
+                                               NewField(FieldError, []byte("Error creating alias")),
                                        },
                                },
                        },
-                       wantErr: false,
                },
                {
                        name: "when user does not have required permission",
@@ -1197,10 +1136,9 @@ func TestHandleMakeAlias(t *testing.T) {
                                cc: &ClientConn{
                                        logger: NewTestLogger(),
                                        Account: &Account{
-                                               Access: func() *[]byte {
+                                               Access: func() accessBitmap {
                                                        var bits accessBitmap
-                                                       access := bits[:]
-                                                       return &access
+                                                       return bits
                                                }(),
                                        },
                                        Server: &Server{
@@ -1213,15 +1151,15 @@ func TestHandleMakeAlias(t *testing.T) {
                                        },
                                },
                                t: NewTransaction(
-                                       tranMakeFileAlias, &[]byte{0, 1},
-                                       NewField(fieldFileName, []byte("testFile")),
-                                       NewField(fieldFilePath, []byte{
+                                       TranMakeFileAlias, [2]byte{0, 1},
+                                       NewField(FieldFileName, []byte("testFile")),
+                                       NewField(FieldFilePath, []byte{
                                                0x00, 0x01,
                                                0x00, 0x00,
                                                0x03,
                                                0x2e, 0x2e, 0x2e,
                                        }),
-                                       NewField(fieldFileNewPath, []byte{
+                                       NewField(FieldFileNewPath, []byte{
                                                0x00, 0x01,
                                                0x00, 0x00,
                                                0x03,
@@ -1231,27 +1169,18 @@ func TestHandleMakeAlias(t *testing.T) {
                        },
                        wantRes: []Transaction{
                                {
-                                       Flags:     0x00,
                                        IsReply:   0x01,
-                                       Type:      []byte{0, 0x00},
-                                       ID:        []byte{0x9a, 0xcb, 0x04, 0x42},
-                                       ErrorCode: []byte{0, 0, 0, 1},
+                                       ErrorCode: [4]byte{0, 0, 0, 1},
                                        Fields: []Field{
-                                               NewField(fieldError, []byte("You are not allowed to make aliases.")),
+                                               NewField(FieldError, []byte("You are not allowed to make aliases.")),
                                        },
                                },
                        },
-                       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)
                })
        }
@@ -1260,24 +1189,22 @@ 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",
                        args: args{
                                cc: &ClientConn{
                                        Account: &Account{
-                                               Access: func() *[]byte {
+                                               Access: func() accessBitmap {
                                                        var bits accessBitmap
                                                        bits.Set(accessOpenUser)
-                                                       access := bits[:]
-                                                       return &access
+                                                       return bits
                                                }(),
                                        },
                                        Server: &Server{
@@ -1286,42 +1213,36 @@ func TestHandleGetUser(t *testing.T) {
                                                                Login:    "guest",
                                                                Name:     "Guest",
                                                                Password: "password",
-                                                               Access:   &[]byte{1},
+                                                               Access:   accessBitmap{},
                                                        },
                                                },
                                        },
                                },
                                t: NewTransaction(
-                                       tranGetUser, &[]byte{0, 1},
-                                       NewField(fieldUserLogin, []byte("guest")),
+                                       TranGetUser, [2]byte{0, 1},
+                                       NewField(FieldUserLogin, []byte("guest")),
                                ),
                        },
                        wantRes: []Transaction{
                                {
-                                       Flags:     0x00,
-                                       IsReply:   0x01,
-                                       Type:      []byte{0x01, 0x60},
-                                       ID:        []byte{0x9a, 0xcb, 0x04, 0x42},
-                                       ErrorCode: []byte{0, 0, 0, 0},
+                                       IsReply: 0x01,
                                        Fields: []Field{
-                                               NewField(fieldUserName, []byte("Guest")),
-                                               NewField(fieldUserLogin, negateString([]byte("guest"))),
-                                               NewField(fieldUserPassword, []byte("password")),
-                                               NewField(fieldUserAccess, []byte{1}),
+                                               NewField(FieldUserName, []byte("Guest")),
+                                               NewField(FieldUserLogin, encodeString([]byte("guest"))),
+                                               NewField(FieldUserPassword, []byte("password")),
+                                               NewField(FieldUserAccess, []byte{0, 0, 0, 0, 0, 0, 0, 0}),
                                        },
                                },
                        },
-                       wantErr: assert.NoError,
                },
                {
                        name: "when user does not have required permission",
                        args: args{
                                cc: &ClientConn{
                                        Account: &Account{
-                                               Access: func() *[]byte {
+                                               Access: func() accessBitmap {
                                                        var bits accessBitmap
-                                                       access := bits[:]
-                                                       return &access
+                                                       return bits
                                                }(),
                                        },
                                        Server: &Server{
@@ -1329,34 +1250,29 @@ func TestHandleGetUser(t *testing.T) {
                                        },
                                },
                                t: NewTransaction(
-                                       tranGetUser, &[]byte{0, 1},
-                                       NewField(fieldUserLogin, []byte("nonExistentUser")),
+                                       TranGetUser, [2]byte{0, 1},
+                                       NewField(FieldUserLogin, []byte("nonExistentUser")),
                                ),
                        },
                        wantRes: []Transaction{
                                {
-                                       Flags:     0x00,
                                        IsReply:   0x01,
-                                       Type:      []byte{0, 0x00},
-                                       ID:        []byte{0x9a, 0xcb, 0x04, 0x42},
-                                       ErrorCode: []byte{0, 0, 0, 1},
+                                       ErrorCode: [4]byte{0, 0, 0, 1},
                                        Fields: []Field{
-                                               NewField(fieldError, []byte("You are not allowed to view accounts.")),
+                                               NewField(FieldError, []byte("You are not allowed to view accounts.")),
                                        },
                                },
                        },
-                       wantErr: assert.NoError,
                },
                {
                        name: "when account does not exist",
                        args: args{
                                cc: &ClientConn{
                                        Account: &Account{
-                                               Access: func() *[]byte {
+                                               Access: func() accessBitmap {
                                                        var bits accessBitmap
                                                        bits.Set(accessOpenUser)
-                                                       access := bits[:]
-                                                       return &access
+                                                       return bits
                                                }(),
                                        },
                                        Server: &Server{
@@ -1364,32 +1280,26 @@ func TestHandleGetUser(t *testing.T) {
                                        },
                                },
                                t: NewTransaction(
-                                       tranGetUser, &[]byte{0, 1},
-                                       NewField(fieldUserLogin, []byte("nonExistentUser")),
+                                       TranGetUser, [2]byte{0, 1},
+                                       NewField(FieldUserLogin, []byte("nonExistentUser")),
                                ),
                        },
                        wantRes: []Transaction{
                                {
                                        Flags:     0x00,
                                        IsReply:   0x01,
-                                       Type:      []byte{0, 0x00},
-                                       ID:        []byte{0x9a, 0xcb, 0x04, 0x42},
-                                       ErrorCode: []byte{0, 0, 0, 1},
+                                       Type:      [2]byte{0, 0},
+                                       ErrorCode: [4]byte{0, 0, 0, 1},
                                        Fields: []Field{
-                                               NewField(fieldError, []byte("Account does not exist.")),
+                                               NewField(FieldError, []byte("Account does not exist.")),
                                        },
                                },
                        },
-                       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)
                })
        }
@@ -1398,24 +1308,22 @@ 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",
                        args: args{
                                cc: &ClientConn{
                                        Account: &Account{
-                                               Access: func() *[]byte {
+                                               Access: func() accessBitmap {
                                                        var bits accessBitmap
                                                        bits.Set(accessDeleteUser)
-                                                       access := bits[:]
-                                                       return &access
+                                                       return bits
                                                }(),
                                        },
                                        Server: &Server{
@@ -1424,7 +1332,7 @@ func TestHandleDeleteUser(t *testing.T) {
                                                                Login:    "testuser",
                                                                Name:     "Testy McTest",
                                                                Password: "password",
-                                                               Access:   &[]byte{1},
+                                                               Access:   accessBitmap{},
                                                        },
                                                },
                                                FS: func() *MockFileStore {
@@ -1435,31 +1343,27 @@ func TestHandleDeleteUser(t *testing.T) {
                                        },
                                },
                                t: NewTransaction(
-                                       tranDeleteUser, &[]byte{0, 1},
-                                       NewField(fieldUserLogin, negateString([]byte("testuser"))),
+                                       TranDeleteUser, [2]byte{0, 1},
+                                       NewField(FieldUserLogin, encodeString([]byte("testuser"))),
                                ),
                        },
                        wantRes: []Transaction{
                                {
-                                       Flags:     0x00,
-                                       IsReply:   0x01,
-                                       Type:      []byte{0x1, 0x5f},
-                                       ID:        []byte{0x9a, 0xcb, 0x04, 0x42},
-                                       ErrorCode: []byte{0, 0, 0, 0},
-                                       Fields:    []Field(nil),
+                                       Flags:   0x00,
+                                       IsReply: 0x01,
+                                       Type:    [2]byte{0, 0},
+                                       Fields:  []Field(nil),
                                },
                        },
-                       wantErr: assert.NoError,
                },
                {
                        name: "when user does not have required permission",
                        args: args{
                                cc: &ClientConn{
                                        Account: &Account{
-                                               Access: func() *[]byte {
+                                               Access: func() accessBitmap {
                                                        var bits accessBitmap
-                                                       access := bits[:]
-                                                       return &access
+                                                       return bits
                                                }(),
                                        },
                                        Server: &Server{
@@ -1467,32 +1371,24 @@ func TestHandleDeleteUser(t *testing.T) {
                                        },
                                },
                                t: NewTransaction(
-                                       tranDeleteUser, &[]byte{0, 1},
-                                       NewField(fieldUserLogin, negateString([]byte("testuser"))),
+                                       TranDeleteUser, [2]byte{0, 1},
+                                       NewField(FieldUserLogin, encodeString([]byte("testuser"))),
                                ),
                        },
                        wantRes: []Transaction{
                                {
-                                       Flags:     0x00,
                                        IsReply:   0x01,
-                                       Type:      []byte{0, 0x00},
-                                       ID:        []byte{0x9a, 0xcb, 0x04, 0x42},
-                                       ErrorCode: []byte{0, 0, 0, 1},
+                                       ErrorCode: [4]byte{0, 0, 0, 1},
                                        Fields: []Field{
-                                               NewField(fieldError, []byte("You are not allowed to delete accounts.")),
+                                               NewField(FieldError, []byte("You are not allowed to delete accounts.")),
                                        },
                                },
                        },
-                       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)
                })
        }
@@ -1501,24 +1397,22 @@ 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",
                        args: args{
                                cc: &ClientConn{
                                        Account: &Account{
-                                               Access: func() *[]byte {
+                                               Access: func() accessBitmap {
                                                        var bits accessBitmap
                                                        bits.Set(accessNewsReadArt)
-                                                       access := bits[:]
-                                                       return &access
+                                                       return bits
                                                }(),
                                        },
                                        Server: &Server{
@@ -1526,32 +1420,26 @@ func TestHandleGetMsgs(t *testing.T) {
                                        },
                                },
                                t: NewTransaction(
-                                       tranGetMsgs, &[]byte{0, 1},
+                                       TranGetMsgs, [2]byte{0, 1},
                                ),
                        },
                        wantRes: []Transaction{
                                {
-                                       Flags:     0x00,
-                                       IsReply:   0x01,
-                                       Type:      []byte{0, 0x65},
-                                       ID:        []byte{0x9a, 0xcb, 0x04, 0x42},
-                                       ErrorCode: []byte{0, 0, 0, 0},
+                                       IsReply: 0x01,
                                        Fields: []Field{
-                                               NewField(fieldData, []byte("TEST")),
+                                               NewField(FieldData, []byte("TEST")),
                                        },
                                },
                        },
-                       wantErr: assert.NoError,
                },
                {
                        name: "when user does not have required permission",
                        args: args{
                                cc: &ClientConn{
                                        Account: &Account{
-                                               Access: func() *[]byte {
+                                               Access: func() accessBitmap {
                                                        var bits accessBitmap
-                                                       access := bits[:]
-                                                       return &access
+                                                       return bits
                                                }(),
                                        },
                                        Server: &Server{
@@ -1559,31 +1447,23 @@ func TestHandleGetMsgs(t *testing.T) {
                                        },
                                },
                                t: NewTransaction(
-                                       tranGetMsgs, &[]byte{0, 1},
+                                       TranGetMsgs, [2]byte{0, 1},
                                ),
                        },
                        wantRes: []Transaction{
                                {
-                                       Flags:     0x00,
                                        IsReply:   0x01,
-                                       Type:      []byte{0, 0x00},
-                                       ID:        []byte{0x9a, 0xcb, 0x04, 0x42},
-                                       ErrorCode: []byte{0, 0, 0, 1},
+                                       ErrorCode: [4]byte{0, 0, 0, 1},
                                        Fields: []Field{
-                                               NewField(fieldError, []byte("You are not allowed to read news.")),
+                                               NewField(FieldError, []byte("You are not allowed to read news.")),
                                        },
                                },
                        },
-                       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)
                })
        }
@@ -1592,23 +1472,21 @@ 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",
                        args: args{
                                cc: &ClientConn{
                                        Account: &Account{
-                                               Access: func() *[]byte {
+                                               Access: func() accessBitmap {
                                                        var bits accessBitmap
-                                                       access := bits[:]
-                                                       return &access
+                                                       return bits
                                                }(),
                                        },
                                        Server: &Server{
@@ -1616,31 +1494,61 @@ func TestHandleNewUser(t *testing.T) {
                                        },
                                },
                                t: NewTransaction(
-                                       tranNewUser, &[]byte{0, 1},
+                                       TranNewUser, [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 create new accounts.")),
+                                       },
+                               },
+                       },
+               },
+               {
+                       name: "when user attempts to create account with greater access",
+                       args: args{
+                               cc: &ClientConn{
+                                       Account: &Account{
+                                               Access: func() accessBitmap {
+                                                       var bits accessBitmap
+                                                       bits.Set(accessCreateUser)
+                                                       return bits
+                                               }(),
+                                       },
+                                       Server: &Server{
+                                               Accounts: map[string]*Account{},
+                                       },
+                               },
+                               t: NewTransaction(
+                                       TranNewUser, [2]byte{0, 1},
+                                       NewField(FieldUserLogin, []byte("userB")),
+                                       NewField(
+                                               FieldUserAccess,
+                                               func() []byte {
+                                                       var bits accessBitmap
+                                                       bits.Set(accessDisconUser)
+                                                       return bits[:]
+                                               }(),
+                                       ),
                                ),
                        },
                        wantRes: []Transaction{
                                {
-                                       Flags:     0x00,
                                        IsReply:   0x01,
-                                       Type:      []byte{0, 0x00},
-                                       ID:        []byte{0x9a, 0xcb, 0x04, 0x42},
-                                       ErrorCode: []byte{0, 0, 0, 1},
+                                       ErrorCode: [4]byte{0, 0, 0, 1},
                                        Fields: []Field{
-                                               NewField(fieldError, []byte("You are not allowed to create new accounts.")),
+                                               NewField(FieldError, []byte("Cannot create account with more access than yourself.")),
                                        },
                                },
                        },
-                       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)
                })
        }
@@ -1649,23 +1557,21 @@ 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",
                        args: args{
                                cc: &ClientConn{
                                        Account: &Account{
-                                               Access: func() *[]byte {
+                                               Access: func() accessBitmap {
                                                        var bits accessBitmap
-                                                       access := bits[:]
-                                                       return &access
+                                                       return bits
                                                }(),
                                        },
                                        Server: &Server{
@@ -1673,33 +1579,28 @@ func TestHandleListUsers(t *testing.T) {
                                        },
                                },
                                t: NewTransaction(
-                                       tranNewUser, &[]byte{0, 1},
+                                       TranNewUser, [2]byte{0, 1},
                                ),
                        },
                        wantRes: []Transaction{
                                {
-                                       Flags:     0x00,
                                        IsReply:   0x01,
-                                       Type:      []byte{0, 0x00},
-                                       ID:        []byte{0x9a, 0xcb, 0x04, 0x42},
-                                       ErrorCode: []byte{0, 0, 0, 1},
+                                       ErrorCode: [4]byte{0, 0, 0, 1},
                                        Fields: []Field{
-                                               NewField(fieldError, []byte("You are not allowed to view accounts.")),
+                                               NewField(FieldError, []byte("You are not allowed to view accounts.")),
                                        },
                                },
                        },
-                       wantErr: assert.NoError,
                },
                {
                        name: "when user has required permission",
                        args: args{
                                cc: &ClientConn{
                                        Account: &Account{
-                                               Access: func() *[]byte {
+                                               Access: func() accessBitmap {
                                                        var bits accessBitmap
                                                        bits.Set(accessOpenUser)
-                                                       access := bits[:]
-                                                       return &access
+                                                       return bits
                                                }(),
                                        },
                                        Server: &Server{
@@ -1708,25 +1609,21 @@ func TestHandleListUsers(t *testing.T) {
                                                                Name:     "guest",
                                                                Login:    "guest",
                                                                Password: "zz",
-                                                               Access:   &[]byte{255, 255, 255, 255, 255, 255, 255, 255},
+                                                               Access:   accessBitmap{255, 255, 255, 255, 255, 255, 255, 255},
                                                        },
                                                },
                                        },
                                },
                                t: NewTransaction(
-                                       tranGetClientInfoText, &[]byte{0, 1},
-                                       NewField(fieldUserID, []byte{0, 1}),
+                                       TranGetClientInfoText, [2]byte{0, 1},
+                                       NewField(FieldUserID, []byte{0, 1}),
                                ),
                        },
                        wantRes: []Transaction{
                                {
-                                       Flags:     0x00,
-                                       IsReply:   0x01,
-                                       Type:      []byte{0x01, 0x2f},
-                                       ID:        []byte{0, 0, 0, 0},
-                                       ErrorCode: []byte{0, 0, 0, 0},
+                                       IsReply: 0x01,
                                        Fields: []Field{
-                                               NewField(fieldData, []byte{
+                                               NewField(FieldData, []byte{
                                                        0x00, 0x04, 0x00, 0x66, 0x00, 0x05, 0x67, 0x75, 0x65, 0x73, 0x74, 0x00, 0x69, 0x00, 0x05, 0x98,
                                                        0x8a, 0x9a, 0x8c, 0x8b, 0x00, 0x6e, 0x00, 0x08, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
                                                        0x00, 0x6a, 0x00, 0x01, 0x78,
@@ -1734,15 +1631,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)
                })
@@ -1752,42 +1645,36 @@ 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",
                        args: args{
                                cc: &ClientConn{
                                        Account: &Account{
-                                               Access: func() *[]byte {
+                                               Access: func() accessBitmap {
                                                        var bits accessBitmap
-                                                       access := bits[:]
-                                                       return &access
+                                                       return bits
                                                }(),
                                        },
                                        Server: &Server{},
                                },
-                               t: NewTransaction(tranDownloadFile, &[]byte{0, 1}),
+                               t: NewTransaction(TranDownloadFile, [2]byte{0, 1}),
                        },
                        wantRes: []Transaction{
                                {
-                                       Flags:     0x00,
                                        IsReply:   0x01,
-                                       Type:      []byte{0, 0x00},
-                                       ID:        []byte{0x9a, 0xcb, 0x04, 0x42},
-                                       ErrorCode: []byte{0, 0, 0, 1},
+                                       ErrorCode: [4]byte{0, 0, 0, 1},
                                        Fields: []Field{
-                                               NewField(fieldError, []byte("You are not allowed to download files.")),
+                                               NewField(FieldError, []byte("You are not allowed to download files.")),
                                        },
                                },
                        },
-                       wantErr: assert.NoError,
                },
                {
                        name: "with a valid file",
@@ -1797,11 +1684,10 @@ func TestHandleDownloadFile(t *testing.T) {
                                                FileDownload: {},
                                        },
                                        Account: &Account{
-                                               Access: func() *[]byte {
+                                               Access: func() accessBitmap {
                                                        var bits accessBitmap
                                                        bits.Set(accessDownloadFile)
-                                                       access := bits[:]
-                                                       return &access
+                                                       return bits
                                                }(),
                                        },
                                        Server: &Server{
@@ -1814,28 +1700,23 @@ func TestHandleDownloadFile(t *testing.T) {
                                        },
                                },
                                t: NewTransaction(
-                                       accessDownloadFile,
-                                       &[]byte{0, 1},
-                                       NewField(fieldFileName, []byte("testfile.txt")),
-                                       NewField(fieldFilePath, []byte{0x0, 0x00}),
+                                       TranDownloadFile,
+                                       [2]byte{0, 1},
+                                       NewField(FieldFileName, []byte("testfile.txt")),
+                                       NewField(FieldFilePath, []byte{0x0, 0x00}),
                                ),
                        },
                        wantRes: []Transaction{
                                {
-                                       Flags:     0x00,
-                                       IsReply:   0x01,
-                                       Type:      []byte{0, 0x2},
-                                       ID:        []byte{0x9a, 0xcb, 0x04, 0x42},
-                                       ErrorCode: []byte{0, 0, 0, 0},
+                                       IsReply: 0x01,
                                        Fields: []Field{
-                                               NewField(fieldRefNum, []byte{0x52, 0xfd, 0xfc, 0x07}),
-                                               NewField(fieldWaitingCount, []byte{0x00, 0x00}),
-                                               NewField(fieldTransferSize, []byte{0x00, 0x00, 0x00, 0xa5}),
-                                               NewField(fieldFileSize, []byte{0x00, 0x00, 0x00, 0x17}),
+                                               NewField(FieldRefNum, []byte{0x52, 0xfd, 0xfc, 0x07}),
+                                               NewField(FieldWaitingCount, []byte{0x00, 0x00}),
+                                               NewField(FieldTransferSize, []byte{0x00, 0x00, 0x00, 0xa5}),
+                                               NewField(FieldFileSize, []byte{0x00, 0x00, 0x00, 0x17}),
                                        },
                                },
                        },
-                       wantErr: assert.NoError,
                },
                {
                        name: "when client requests to resume 1k test file at offset 256",
@@ -1844,11 +1725,10 @@ func TestHandleDownloadFile(t *testing.T) {
                                        transfers: map[int]map[[4]byte]*FileTransfer{
                                                FileDownload: {},
                                        }, Account: &Account{
-                                               Access: func() *[]byte {
+                                               Access: func() accessBitmap {
                                                        var bits accessBitmap
                                                        bits.Set(accessDownloadFile)
-                                                       access := bits[:]
-                                                       return &access
+                                                       return bits
                                                }(),
                                        },
                                        Server: &Server{
@@ -1879,30 +1759,23 @@ func TestHandleDownloadFile(t *testing.T) {
                                        },
                                },
                                t: NewTransaction(
-                                       accessDownloadFile,
-                                       &[]byte{0, 1},
-                                       NewField(fieldFileName, []byte("testfile-1k")),
-                                       NewField(fieldFilePath, []byte{0x00, 0x00}),
+                                       TranDownloadFile,
+                                       [2]byte{0, 1},
+                                       NewField(FieldFileName, []byte("testfile-1k")),
+                                       NewField(FieldFilePath, []byte{0x00, 0x00}),
                                        NewField(
-                                               fieldFileResumeData,
+                                               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{},
                                                                        },
                                                                },
                                                        }
@@ -1914,29 +1787,20 @@ func TestHandleDownloadFile(t *testing.T) {
                        },
                        wantRes: []Transaction{
                                {
-                                       Flags:     0x00,
-                                       IsReply:   0x01,
-                                       Type:      []byte{0, 0x2},
-                                       ID:        []byte{0x9a, 0xcb, 0x04, 0x42},
-                                       ErrorCode: []byte{0, 0, 0, 0},
+                                       IsReply: 0x01,
                                        Fields: []Field{
-                                               NewField(fieldRefNum, []byte{0x52, 0xfd, 0xfc, 0x07}),
-                                               NewField(fieldWaitingCount, []byte{0x00, 0x00}),
-                                               NewField(fieldTransferSize, []byte{0x00, 0x00, 0x03, 0x8d}),
-                                               NewField(fieldFileSize, []byte{0x00, 0x00, 0x03, 0x00}),
+                                               NewField(FieldRefNum, []byte{0x52, 0xfd, 0xfc, 0x07}),
+                                               NewField(FieldWaitingCount, []byte{0x00, 0x00}),
+                                               NewField(FieldTransferSize, []byte{0x00, 0x00, 0x03, 0x8d}),
+                                               NewField(FieldFileSize, []byte{0x00, 0x00, 0x03, 0x00}),
                                        },
                                },
                        },
-                       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)
                })
        }
@@ -1945,13 +1809,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",
@@ -1962,32 +1825,31 @@ func TestHandleUpdateUser(t *testing.T) {
                                                Logger: NewTestLogger(),
                                        },
                                        Account: &Account{
-                                               Access: func() *[]byte {
+                                               Access: func() accessBitmap {
                                                        var bits accessBitmap
-                                                       access := bits[:]
-                                                       return &access
+                                                       return bits
                                                }(),
                                        },
                                },
                                t: NewTransaction(
-                                       tranUpdateUser,
-                                       &[]byte{0, 0},
-                                       NewField(fieldData, []byte{
+                                       TranUpdateUser,
+                                       [2]byte{0, 0},
+                                       NewField(FieldData, []byte{
                                                0x00, 0x04, // field count
 
-                                               0x00, 0x69, // fieldUserLogin = 105
+                                               0x00, 0x69, // FieldUserLogin = 105
                                                0x00, 0x03,
                                                0x9d, 0x9d, 0x9d,
 
-                                               0x00, 0x6a, // fieldUserPassword = 106
+                                               0x00, 0x6a, // FieldUserPassword = 106
                                                0x00, 0x03,
                                                0x9c, 0x9c, 0x9c,
 
-                                               0x00, 0x66, // fieldUserName = 102
+                                               0x00, 0x66, // FieldUserName = 102
                                                0x00, 0x03,
                                                0x61, 0x61, 0x61,
 
-                                               0x00, 0x6e, // fieldUserAccess = 110
+                                               0x00, 0x6e, // FieldUserAccess = 110
                                                0x00, 0x08,
                                                0x60, 0x70, 0x0c, 0x20, 0x03, 0x80, 0x00, 0x00,
                                        }),
@@ -1995,17 +1857,13 @@ func TestHandleUpdateUser(t *testing.T) {
                        },
                        wantRes: []Transaction{
                                {
-                                       Flags:     0x00,
                                        IsReply:   0x01,
-                                       Type:      []byte{0, 0x00},
-                                       ID:        []byte{0x9a, 0xcb, 0x04, 0x42},
-                                       ErrorCode: []byte{0, 0, 0, 1},
+                                       ErrorCode: [4]byte{0, 0, 0, 1},
                                        Fields: []Field{
-                                               NewField(fieldError, []byte("You are not allowed to create new accounts.")),
+                                               NewField(FieldError, []byte("You are not allowed to create new accounts.")),
                                        },
                                },
                        },
-                       wantErr: assert.NoError,
                },
                {
                        name: "when action is modify user without required permission",
@@ -2019,32 +1877,31 @@ func TestHandleUpdateUser(t *testing.T) {
                                                },
                                        },
                                        Account: &Account{
-                                               Access: func() *[]byte {
+                                               Access: func() accessBitmap {
                                                        var bits accessBitmap
-                                                       access := bits[:]
-                                                       return &access
+                                                       return bits
                                                }(),
                                        },
                                },
                                t: NewTransaction(
-                                       tranUpdateUser,
-                                       &[]byte{0, 0},
-                                       NewField(fieldData, []byte{
+                                       TranUpdateUser,
+                                       [2]byte{0, 0},
+                                       NewField(FieldData, []byte{
                                                0x00, 0x04, // field count
 
-                                               0x00, 0x69, // fieldUserLogin = 105
+                                               0x00, 0x69, // FieldUserLogin = 105
                                                0x00, 0x03,
                                                0x9d, 0x9d, 0x9d,
 
-                                               0x00, 0x6a, // fieldUserPassword = 106
+                                               0x00, 0x6a, // FieldUserPassword = 106
                                                0x00, 0x03,
                                                0x9c, 0x9c, 0x9c,
 
-                                               0x00, 0x66, // fieldUserName = 102
+                                               0x00, 0x66, // FieldUserName = 102
                                                0x00, 0x03,
                                                0x61, 0x61, 0x61,
 
-                                               0x00, 0x6e, // fieldUserAccess = 110
+                                               0x00, 0x6e, // FieldUserAccess = 110
                                                0x00, 0x08,
                                                0x60, 0x70, 0x0c, 0x20, 0x03, 0x80, 0x00, 0x00,
                                        }),
@@ -2052,17 +1909,13 @@ func TestHandleUpdateUser(t *testing.T) {
                        },
                        wantRes: []Transaction{
                                {
-                                       Flags:     0x00,
                                        IsReply:   0x01,
-                                       Type:      []byte{0, 0x00},
-                                       ID:        []byte{0x9a, 0xcb, 0x04, 0x42},
-                                       ErrorCode: []byte{0, 0, 0, 1},
+                                       ErrorCode: [4]byte{0, 0, 0, 1},
                                        Fields: []Field{
-                                               NewField(fieldError, []byte("You are not allowed to modify accounts.")),
+                                               NewField(FieldError, []byte("You are not allowed to modify accounts.")),
                                        },
                                },
                        },
-                       wantErr: assert.NoError,
                },
                {
                        name: "when action is delete user without required permission",
@@ -2075,17 +1928,16 @@ func TestHandleUpdateUser(t *testing.T) {
                                                },
                                        },
                                        Account: &Account{
-                                               Access: func() *[]byte {
+                                               Access: func() accessBitmap {
                                                        var bits accessBitmap
-                                                       access := bits[:]
-                                                       return &access
+                                                       return bits
                                                }(),
                                        },
                                },
                                t: NewTransaction(
-                                       tranUpdateUser,
-                                       &[]byte{0, 0},
-                                       NewField(fieldData, []byte{
+                                       TranUpdateUser,
+                                       [2]byte{0, 0},
+                                       NewField(FieldData, []byte{
                                                0x00, 0x01,
                                                0x00, 0x65,
                                                0x00, 0x03,
@@ -2095,26 +1947,18 @@ func TestHandleUpdateUser(t *testing.T) {
                        },
                        wantRes: []Transaction{
                                {
-                                       Flags:     0x00,
                                        IsReply:   0x01,
-                                       Type:      []byte{0, 0x00},
-                                       ID:        []byte{0x9a, 0xcb, 0x04, 0x42},
-                                       ErrorCode: []byte{0, 0, 0, 1},
+                                       ErrorCode: [4]byte{0, 0, 0, 1},
                                        Fields: []Field{
-                                               NewField(fieldError, []byte("You are not allowed to delete accounts.")),
+                                               NewField(FieldError, []byte("You are not allowed to delete accounts.")),
                                        },
                                },
                        },
-                       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)
                })
        }
@@ -2123,52 +1967,43 @@ 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",
                        args: args{
                                cc: &ClientConn{
                                        Account: &Account{
-                                               Access: func() *[]byte {
+                                               Access: func() accessBitmap {
                                                        var bits accessBitmap
-                                                       access := bits[:]
-                                                       return &access
+                                                       return bits
                                                }(),
                                        },
                                },
                                t: NewTransaction(
-                                       tranDelNewsArt,
-                                       &[]byte{0, 0},
+                                       TranDelNewsArt,
+                                       [2]byte{0, 0},
                                ),
                        },
                        wantRes: []Transaction{
                                {
-                                       Flags:     0x00,
                                        IsReply:   0x01,
-                                       Type:      []byte{0, 0x00},
-                                       ID:        []byte{0x9a, 0xcb, 0x04, 0x42},
-                                       ErrorCode: []byte{0, 0, 0, 1},
+                                       ErrorCode: [4]byte{0, 0, 0, 1},
                                        Fields: []Field{
-                                               NewField(fieldError, []byte("You are not allowed to delete news articles.")),
+                                               NewField(FieldError, []byte("You are not allowed to delete news articles.")),
                                        },
                                },
                        },
-                       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)
                })
        }
@@ -2177,100 +2012,85 @@ 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",
                        args: args{
                                cc: &ClientConn{
                                        Account: &Account{
-                                               Access: func() *[]byte {
+                                               Access: func() accessBitmap {
                                                        var bits accessBitmap
-                                                       access := bits[:]
-                                                       return &access
+                                                       return bits
                                                }(),
                                        },
                                },
                                t: NewTransaction(
-                                       tranDelNewsArt,
-                                       &[]byte{0, 0},
+                                       TranDelNewsArt,
+                                       [2]byte{0, 0},
                                ),
                        },
                        wantRes: []Transaction{
                                {
-                                       Flags:     0x00,
                                        IsReply:   0x01,
-                                       Type:      []byte{0, 0x00},
-                                       ID:        []byte{0x9a, 0xcb, 0x04, 0x42},
-                                       ErrorCode: []byte{0, 0, 0, 1},
+                                       ErrorCode: [4]byte{0, 0, 0, 1},
                                        Fields: []Field{
-                                               NewField(fieldError, []byte("You are not allowed to disconnect users.")),
+                                               NewField(FieldError, []byte("You are not allowed to disconnect users.")),
                                        },
                                },
                        },
-                       wantErr: assert.NoError,
                },
                {
                        name: "when target user has 'cannot be disconnected' priv",
                        args: args{
                                cc: &ClientConn{
                                        Server: &Server{
-                                               Clients: map[uint16]*ClientConn{
-                                                       uint16(1): {
+                                               Clients: map[[2]byte]*ClientConn{
+                                                       [2]byte{0, 1}: {
                                                                Account: &Account{
                                                                        Login: "unnamed",
-                                                                       Access: func() *[]byte {
+                                                                       Access: func() accessBitmap {
                                                                                var bits accessBitmap
                                                                                bits.Set(accessCannotBeDiscon)
-                                                                               access := bits[:]
-                                                                               return &access
+                                                                               return bits
                                                                        }(),
                                                                },
                                                        },
                                                },
                                        },
                                        Account: &Account{
-                                               Access: func() *[]byte {
+                                               Access: func() accessBitmap {
                                                        var bits accessBitmap
                                                        bits.Set(accessDisconUser)
-                                                       access := bits[:]
-                                                       return &access
+                                                       return bits
                                                }(),
                                        },
                                },
                                t: NewTransaction(
-                                       tranDelNewsArt,
-                                       &[]byte{0, 0},
-                                       NewField(fieldUserID, []byte{0, 1}),
+                                       TranDelNewsArt,
+                                       [2]byte{0, 0},
+                                       NewField(FieldUserID, []byte{0, 1}),
                                ),
                        },
                        wantRes: []Transaction{
                                {
-                                       Flags:     0x00,
                                        IsReply:   0x01,
-                                       Type:      []byte{0, 0x00},
-                                       ID:        []byte{0x9a, 0xcb, 0x04, 0x42},
-                                       ErrorCode: []byte{0, 0, 0, 1},
+                                       ErrorCode: [4]byte{0, 0, 0, 1},
                                        Fields: []Field{
-                                               NewField(fieldError, []byte("unnamed is not allowed to be disconnected.")),
+                                               NewField(FieldError, []byte("unnamed is not allowed to be disconnected.")),
                                        },
                                },
                        },
-                       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)
                })
        }
@@ -2279,66 +2099,102 @@ 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",
+                       args: args{
+                               cc: &ClientConn{
+                                       Account: &Account{
+                                               Access: func() accessBitmap {
+                                                       var bits accessBitmap
+                                                       return bits
+                                               }(),
+                                       },
+                               },
+                               t: NewTransaction(
+                                       TranDelNewsArt,
+                                       [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 send private messages.")),
+                                       },
+                               },
+                       },
+               },
                {
                        name: "when client 1 sends a message to client 2",
                        args: args{
                                cc: &ClientConn{
-                                       ID:       &[]byte{0, 1},
+                                       Account: &Account{
+                                               Access: func() accessBitmap {
+                                                       var bits accessBitmap
+                                                       bits.Set(accessSendPrivMsg)
+                                                       return bits
+                                               }(),
+                                       },
+                                       ID:       [2]byte{0, 1},
                                        UserName: []byte("User1"),
                                        Server: &Server{
-                                               Clients: map[uint16]*ClientConn{
-                                                       uint16(2): {
+                                               Clients: map[[2]byte]*ClientConn{
+                                                       [2]byte{0, 2}: {
                                                                AutoReply: []byte(nil),
+                                                               Flags:     [2]byte{0, 0},
                                                        },
                                                },
                                        },
                                },
                                t: NewTransaction(
-                                       tranSendInstantMsg,
-                                       &[]byte{0, 1},
-                                       NewField(fieldData, []byte("hai")),
-                                       NewField(fieldUserID, []byte{0, 2}),
+                                       TranSendInstantMsg,
+                                       [2]byte{0, 1},
+                                       NewField(FieldData, []byte("hai")),
+                                       NewField(FieldUserID, []byte{0, 2}),
                                ),
                        },
                        wantRes: []Transaction{
-                               *NewTransaction(
-                                       tranServerMsg,
-                                       &[]byte{0, 2},
-                                       NewField(fieldData, []byte("hai")),
-                                       NewField(fieldUserName, []byte("User1")),
-                                       NewField(fieldUserID, []byte{0, 1}),
-                                       NewField(fieldOptions, []byte{0, 1}),
+                               NewTransaction(
+                                       TranServerMsg,
+                                       [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},
-                                       Flags:     0x00,
-                                       IsReply:   0x01,
-                                       Type:      []byte{0x0, 0x6c},
-                                       ID:        []byte{0, 0, 0, 0},
-                                       ErrorCode: []byte{0, 0, 0, 0},
-                                       Fields:    []Field(nil),
+                                       clientID: [2]byte{0, 1},
+                                       IsReply:  0x01,
+                                       Fields:   []Field(nil),
                                },
                        },
-                       wantErr: assert.NoError,
                },
                {
                        name: "when client 2 has autoreply enabled",
                        args: args{
                                cc: &ClientConn{
-                                       ID:       &[]byte{0, 1},
+                                       Account: &Account{
+                                               Access: func() accessBitmap {
+                                                       var bits accessBitmap
+                                                       bits.Set(accessSendPrivMsg)
+                                                       return bits
+                                               }(),
+                                       },
+                                       ID:       [2]byte{0, 1},
                                        UserName: []byte("User1"),
                                        Server: &Server{
-                                               Clients: map[uint16]*ClientConn{
-                                                       uint16(2): {
-                                                               ID:        &[]byte{0, 2},
+                                               Clients: map[[2]byte]*ClientConn{
+                                                       [2]byte{0, 2}: {
+                                                               Flags:     [2]byte{0, 0},
+                                                               ID:        [2]byte{0, 2},
                                                                UserName:  []byte("User2"),
                                                                AutoReply: []byte("autohai"),
                                                        },
@@ -2346,79 +2202,114 @@ func TestHandleSendInstantMsg(t *testing.T) {
                                        },
                                },
                                t: NewTransaction(
-                                       tranSendInstantMsg,
-                                       &[]byte{0, 1},
-                                       NewField(fieldData, []byte("hai")),
-                                       NewField(fieldUserID, []byte{0, 2}),
+                                       TranSendInstantMsg,
+                                       [2]byte{0, 1},
+                                       NewField(FieldData, []byte("hai")),
+                                       NewField(FieldUserID, []byte{0, 2}),
                                ),
                        },
                        wantRes: []Transaction{
-                               *NewTransaction(
-                                       tranServerMsg,
-                                       &[]byte{0, 2},
-                                       NewField(fieldData, []byte("hai")),
-                                       NewField(fieldUserName, []byte("User1")),
-                                       NewField(fieldUserID, []byte{0, 1}),
-                                       NewField(fieldOptions, []byte{0, 1}),
+                               NewTransaction(
+                                       TranServerMsg,
+                                       [2]byte{0, 2},
+                                       NewField(FieldData, []byte("hai")),
+                                       NewField(FieldUserName, []byte("User1")),
+                                       NewField(FieldUserID, []byte{0, 1}),
+                                       NewField(FieldOptions, []byte{0, 1}),
                                ),
-                               *NewTransaction(
-                                       tranServerMsg,
-                                       &[]byte{0, 1},
-                                       NewField(fieldData, []byte("autohai")),
-                                       NewField(fieldUserName, []byte("User2")),
-                                       NewField(fieldUserID, []byte{0, 2}),
-                                       NewField(fieldOptions, []byte{0, 1}),
+                               NewTransaction(
+                                       TranServerMsg,
+                                       [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},
-                                       Flags:     0x00,
-                                       IsReply:   0x01,
-                                       Type:      []byte{0x0, 0x6c},
-                                       ID:        []byte{0, 0, 0, 0},
-                                       ErrorCode: []byte{0, 0, 0, 0},
-                                       Fields:    []Field(nil),
+                                       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
-                       }
-
-                       tranAssertEqual(t, tt.wantRes, gotRes)
-               })
-       }
-}
-
-func TestHandleDeleteFile(t *testing.T) {
-       type args struct {
-               cc *ClientConn
-               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",
+                       name: "when client 2 has refuse private messages enabled",
                        args: args{
                                cc: &ClientConn{
                                        Account: &Account{
-                                               Access: func() *[]byte {
+                                               Access: func() accessBitmap {
                                                        var bits accessBitmap
-                                                       access := bits[:]
-                                                       return &access
+                                                       bits.Set(accessSendPrivMsg)
+                                                       return bits
                                                }(),
                                        },
+                                       ID:       [2]byte{0, 1},
+                                       UserName: []byte("User1"),
                                        Server: &Server{
-                                               Config: &Config{
-                                                       FileRoot: func() string {
+                                               Clients: map[[2]byte]*ClientConn{
+                                                       [2]byte{0, 2}: {
+                                                               Flags:    [2]byte{255, 255},
+                                                               ID:       [2]byte{0, 2},
+                                                               UserName: []byte("User2"),
+                                                       },
+                                               },
+                                       },
+                               },
+                               t: NewTransaction(
+                                       TranSendInstantMsg,
+                                       [2]byte{0, 1},
+                                       NewField(FieldData, []byte("hai")),
+                                       NewField(FieldUserID, []byte{0, 2}),
+                               ),
+                       },
+                       wantRes: []Transaction{
+                               NewTransaction(
+                                       TranServerMsg,
+                                       [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: [2]byte{0, 1},
+                                       IsReply:  0x01,
+                                       Fields:   []Field(nil),
+                               },
+                       },
+               },
+       }
+       for _, tt := range tests {
+               t.Run(tt.name, func(t *testing.T) {
+                       gotRes := HandleSendInstantMsg(tt.args.cc, &tt.args.t)
+                       tranAssertEqual(t, tt.wantRes, gotRes)
+               })
+       }
+}
+
+func TestHandleDeleteFile(t *testing.T) {
+       type args struct {
+               cc *ClientConn
+               t  Transaction
+       }
+       tests := []struct {
+               name    string
+               args    args
+               wantRes []Transaction
+       }{
+               {
+                       name: "when user does not have required permission to delete a folder",
+                       args: args{
+                               cc: &ClientConn{
+                                       Account: &Account{
+                                               Access: func() accessBitmap {
+                                                       var bits accessBitmap
+                                                       return bits
+                                               }(),
+                                       },
+                                       Server: &Server{
+                                               Config: &Config{
+                                                       FileRoot: func() string {
                                                                return "/fakeRoot/Files"
                                                        }(),
                                                },
@@ -2441,9 +2332,9 @@ func TestHandleDeleteFile(t *testing.T) {
                                        },
                                },
                                t: NewTransaction(
-                                       tranDeleteFile, &[]byte{0, 1},
-                                       NewField(fieldFileName, []byte("testfile")),
-                                       NewField(fieldFilePath, []byte{
+                                       TranDeleteFile, [2]byte{0, 1},
+                                       NewField(FieldFileName, []byte("testfile")),
+                                       NewField(FieldFilePath, []byte{
                                                0x00, 0x01,
                                                0x00, 0x00,
                                                0x03,
@@ -2453,28 +2344,23 @@ func TestHandleDeleteFile(t *testing.T) {
                        },
                        wantRes: []Transaction{
                                {
-                                       Flags:     0x00,
                                        IsReply:   0x01,
-                                       Type:      []byte{0, 0x00},
-                                       ID:        []byte{0x9a, 0xcb, 0x04, 0x42},
-                                       ErrorCode: []byte{0, 0, 0, 1},
+                                       ErrorCode: [4]byte{0, 0, 0, 1},
                                        Fields: []Field{
-                                               NewField(fieldError, []byte("You are not allowed to delete files.")),
+                                               NewField(FieldError, []byte("You are not allowed to delete files.")),
                                        },
                                },
                        },
-                       wantErr: assert.NoError,
                },
                {
                        name: "deletes all associated metadata files",
                        args: args{
                                cc: &ClientConn{
                                        Account: &Account{
-                                               Access: func() *[]byte {
+                                               Access: func() accessBitmap {
                                                        var bits accessBitmap
                                                        bits.Set(accessDeleteFile)
-                                                       access := bits[:]
-                                                       return &access
+                                                       return bits
                                                }(),
                                        },
                                        Server: &Server{
@@ -2507,9 +2393,9 @@ func TestHandleDeleteFile(t *testing.T) {
                                        },
                                },
                                t: NewTransaction(
-                                       tranDeleteFile, &[]byte{0, 1},
-                                       NewField(fieldFileName, []byte("testfile")),
-                                       NewField(fieldFilePath, []byte{
+                                       TranDeleteFile, [2]byte{0, 1},
+                                       NewField(FieldFileName, []byte("testfile")),
+                                       NewField(FieldFilePath, []byte{
                                                0x00, 0x01,
                                                0x00, 0x00,
                                                0x03,
@@ -2519,24 +2405,15 @@ func TestHandleDeleteFile(t *testing.T) {
                        },
                        wantRes: []Transaction{
                                {
-                                       Flags:     0x00,
-                                       IsReply:   0x01,
-                                       Type:      []byte{0x0, 0xcc},
-                                       ID:        []byte{0x0, 0x0, 0x0, 0x0},
-                                       ErrorCode: []byte{0, 0, 0, 0},
-                                       Fields:    []Field(nil),
+                                       IsReply: 0x01,
+                                       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)
@@ -2547,23 +2424,21 @@ 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{
-                                               Access: func() *[]byte {
+                                               Access: func() accessBitmap {
                                                        var bits accessBitmap
-                                                       access := bits[:]
-                                                       return &access
+                                                       return bits
                                                }(),
                                        },
                                        Server: &Server{
@@ -2577,8 +2452,8 @@ func TestHandleGetFileNameList(t *testing.T) {
                                        },
                                },
                                t: NewTransaction(
-                                       tranGetFileNameList, &[]byte{0, 1},
-                                       NewField(fieldFilePath, []byte{
+                                       TranGetFileNameList, [2]byte{0, 1},
+                                       NewField(FieldFilePath, []byte{
                                                0x00, 0x01,
                                                0x00, 0x00,
                                                0x08,
@@ -2588,17 +2463,13 @@ func TestHandleGetFileNameList(t *testing.T) {
                        },
                        wantRes: []Transaction{
                                {
-                                       Flags:     0x00,
                                        IsReply:   0x01,
-                                       Type:      []byte{0, 0x00},
-                                       ID:        []byte{0, 0, 0, 0},
-                                       ErrorCode: []byte{0, 0, 0, 1},
+                                       ErrorCode: [4]byte{0, 0, 0, 1},
                                        Fields: []Field{
-                                               NewField(fieldError, []byte("You are not allowed to view drop boxes.")),
+                                               NewField(FieldError, []byte("You are not allowed to view drop boxes.")),
                                        },
                                },
                        },
-                       wantErr: assert.NoError,
                },
                {
                        name: "with file root",
@@ -2614,8 +2485,8 @@ func TestHandleGetFileNameList(t *testing.T) {
                                        },
                                },
                                t: NewTransaction(
-                                       tranGetFileNameList, &[]byte{0, 1},
-                                       NewField(fieldFilePath, []byte{
+                                       TranGetFileNameList, [2]byte{0, 1},
+                                       NewField(FieldFilePath, []byte{
                                                0x00, 0x00,
                                                0x00, 0x00,
                                        }),
@@ -2623,14 +2494,10 @@ func TestHandleGetFileNameList(t *testing.T) {
                        },
                        wantRes: []Transaction{
                                {
-                                       Flags:     0x00,
-                                       IsReply:   0x01,
-                                       Type:      []byte{0, 0xc8},
-                                       ID:        []byte{0, 0, 0, 0},
-                                       ErrorCode: []byte{0, 0, 0, 0},
+                                       IsReply: 0x01,
                                        Fields: []Field{
                                                NewField(
-                                                       fieldFileNameWithInfo,
+                                                       FieldFileNameWithInfo,
                                                        func() []byte {
                                                                fnwi := FileNameWithInfo{
                                                                        fileNameWithInfoHeader: fileNameWithInfoHeader{
@@ -2641,25 +2508,20 @@ func TestHandleGetFileNameList(t *testing.T) {
                                                                                NameScript: [2]byte{},
                                                                                NameSize:   [2]byte{0, 0x0b},
                                                                        },
-                                                                       name: []byte("testfile-1k"),
+                                                                       Name: []byte("testfile-1k"),
                                                                }
-                                                               b, _ := fnwi.MarshalBinary()
+                                                               b, _ := io.ReadAll(&fnwi)
                                                                return b
                                                        }(),
                                                ),
                                        },
                                },
                        },
-                       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)
                })
        }
@@ -2668,23 +2530,21 @@ 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",
                        args: args{
                                cc: &ClientConn{
                                        Account: &Account{
-                                               Access: func() *[]byte {
+                                               Access: func() accessBitmap {
                                                        var bits accessBitmap
-                                                       access := bits[:]
-                                                       return &access
+                                                       return bits
                                                }(),
                                        },
                                        Server: &Server{
@@ -2692,23 +2552,19 @@ func TestHandleGetClientInfoText(t *testing.T) {
                                        },
                                },
                                t: NewTransaction(
-                                       tranGetClientInfoText, &[]byte{0, 1},
-                                       NewField(fieldUserID, []byte{0, 1}),
+                                       TranGetClientInfoText, [2]byte{0, 1},
+                                       NewField(FieldUserID, []byte{0, 1}),
                                ),
                        },
                        wantRes: []Transaction{
                                {
-                                       Flags:     0x00,
                                        IsReply:   0x01,
-                                       Type:      []byte{0, 0x00},
-                                       ID:        []byte{0, 0, 0, 0},
-                                       ErrorCode: []byte{0, 0, 0, 1},
+                                       ErrorCode: [4]byte{0, 0, 0, 1},
                                        Fields: []Field{
-                                               NewField(fieldError, []byte("You are not allowed to get client info.")),
+                                               NewField(FieldError, []byte("You are not allowed to get client info.")),
                                        },
                                },
                        },
-                       wantErr: assert.NoError,
                },
                {
                        name: "with a valid user",
@@ -2717,27 +2573,25 @@ func TestHandleGetClientInfoText(t *testing.T) {
                                        UserName:   []byte("Testy McTest"),
                                        RemoteAddr: "1.2.3.4:12345",
                                        Account: &Account{
-                                               Access: func() *[]byte {
+                                               Access: func() accessBitmap {
                                                        var bits accessBitmap
                                                        bits.Set(accessGetClientInfo)
-                                                       access := bits[:]
-                                                       return &access
+                                                       return bits
                                                }(),
                                                Name:  "test",
                                                Login: "test",
                                        },
                                        Server: &Server{
                                                Accounts: map[string]*Account{},
-                                               Clients: map[uint16]*ClientConn{
-                                                       uint16(1): {
+                                               Clients: map[[2]byte]*ClientConn{
+                                                       [2]byte{0, 1}: {
                                                                UserName:   []byte("Testy McTest"),
                                                                RemoteAddr: "1.2.3.4:12345",
                                                                Account: &Account{
-                                                                       Access: func() *[]byte {
+                                                                       Access: func() accessBitmap {
                                                                                var bits accessBitmap
                                                                                bits.Set(accessGetClientInfo)
-                                                                               access := bits[:]
-                                                                               return &access
+                                                                               return bits
                                                                        }(),
                                                                        Name:  "test",
                                                                        Login: "test",
@@ -2753,20 +2607,16 @@ func TestHandleGetClientInfoText(t *testing.T) {
                                        },
                                },
                                t: NewTransaction(
-                                       tranGetClientInfoText, &[]byte{0, 1},
-                                       NewField(fieldUserID, []byte{0, 1}),
+                                       TranGetClientInfoText, [2]byte{0, 1},
+                                       NewField(FieldUserID, []byte{0, 1}),
                                ),
                        },
                        wantRes: []Transaction{
                                {
-                                       Flags:     0x00,
-                                       IsReply:   0x01,
-                                       Type:      []byte{0x1, 0x2f},
-                                       ID:        []byte{0, 0, 0, 0},
-                                       ErrorCode: []byte{0, 0, 0, 0},
+                                       IsReply: 0x01,
                                        Fields: []Field{
-                                               NewField(fieldData, []byte(
-                                                       strings.Replace(`Nickname:   Testy McTest
+                                               NewField(FieldData, []byte(
+                                                       strings.ReplaceAll(`Nickname:   Testy McTest
 Name:       test
 Account:    test
 Address:    1.2.3.4:12345
@@ -2791,21 +2641,17 @@ None.
 
 None.
 
-`, "\n", "\r", -1)),
+`, "\n", "\r")),
                                                ),
-                                               NewField(fieldUserName, []byte("Testy McTest")),
+                                               NewField(FieldUserName, []byte("Testy McTest")),
                                        },
                                },
                        },
-                       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)
                })
        }
@@ -2814,30 +2660,28 @@ 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",
                        args: args{
                                cc: &ClientConn{
                                        Account: &Account{
-                                               Access: func() *[]byte {
+                                               Access: func() accessBitmap {
                                                        var bits accessBitmap
                                                        bits.Set(accessDisconUser)
                                                        bits.Set(accessAnyName)
-                                                       access := bits[:]
-                                                       return &access
+                                                       return bits
                                                }()},
-                                       Icon:    &[]byte{0, 1},
-                                       Flags:   &[]byte{0, 1},
-                                       Version: &[]byte{0, 1},
-                                       ID:      &[]byte{0, 1},
+                                       Icon:    []byte{0, 1},
+                                       Flags:   [2]byte{0, 1},
+                                       Version: []byte{0, 1},
+                                       ID:      [2]byte{0, 1},
                                        logger:  NewTestLogger(),
                                        Server: &Server{
                                                Config: &Config{
@@ -2846,44 +2690,903 @@ func TestHandleTranAgreed(t *testing.T) {
                                        },
                                },
                                t: NewTransaction(
-                                       tranAgreed, nil,
-                                       NewField(fieldUserName, []byte("username")),
-                                       NewField(fieldUserIconID, []byte{0, 1}),
-                                       NewField(fieldOptions, []byte{0, 0}),
+                                       TranAgreed, [2]byte{},
+                                       NewField(FieldUserName, []byte("username")),
+                                       NewField(FieldUserIconID, []byte{0, 1}),
+                                       NewField(FieldOptions, []byte{0, 0}),
                                ),
                        },
                        wantRes: []Transaction{
                                {
-                                       clientID:  &[]byte{0, 1},
-                                       Flags:     0x00,
-                                       IsReply:   0x00,
-                                       Type:      []byte{0, 0x7a},
-                                       ID:        []byte{0, 0, 0, 0},
-                                       ErrorCode: []byte{0, 0, 0, 0},
+                                       clientID: [2]byte{0, 1},
+                                       Type:     [2]byte{0, 0x7a},
                                        Fields: []Field{
-                                               NewField(fieldBannerType, []byte("JPEG")),
+                                               NewField(FieldBannerType, []byte("JPEG")),
                                        },
                                },
                                {
-                                       clientID:  &[]byte{0, 1},
-                                       Flags:     0x00,
+                                       clientID: [2]byte{0, 1},
+                                       IsReply:  0x01,
+                                       Fields:   []Field{},
+                               },
+                       },
+               },
+       }
+       for _, tt := range tests {
+               t.Run(tt.name, func(t *testing.T) {
+                       gotRes := HandleTranAgreed(tt.args.cc, &tt.args.t)
+                       tranAssertEqual(t, tt.wantRes, gotRes)
+               })
+       }
+}
+
+func TestHandleSetClientUserInfo(t *testing.T) {
+       type args struct {
+               cc *ClientConn
+               t  Transaction
+       }
+       tests := []struct {
+               name    string
+               args    args
+               wantRes []Transaction
+       }{
+               {
+                       name: "when client does not have accessAnyName",
+                       args: args{
+                               cc: &ClientConn{
+                                       Account: &Account{
+                                               Access: func() accessBitmap {
+                                                       var bits accessBitmap
+                                                       return bits
+                                               }(),
+                                       },
+                                       ID:       [2]byte{0, 1},
+                                       UserName: []byte("Guest"),
+                                       Flags:    [2]byte{0, 1},
+                                       Server: &Server{
+                                               Clients: map[[2]byte]*ClientConn{
+                                                       [2]byte{0, 1}: {
+                                                               ID: [2]byte{0, 1},
+                                                       },
+                                               },
+                                       },
+                               },
+                               t: NewTransaction(
+                                       TranSetClientUserInfo, [2]byte{},
+                                       NewField(FieldUserIconID, []byte{0, 1}),
+                                       NewField(FieldUserName, []byte("NOPE")),
+                               ),
+                       },
+                       wantRes: []Transaction{
+                               {
+                                       clientID: [2]byte{0, 1},
+                                       Type:     [2]byte{0x01, 0x2d},
+                                       Fields: []Field{
+                                               NewField(FieldUserID, []byte{0, 1}),
+                                               NewField(FieldUserIconID, []byte{0, 1}),
+                                               NewField(FieldUserFlags, []byte{0, 1}),
+                                               NewField(FieldUserName, []byte("Guest"))},
+                               },
+                       },
+               },
+       }
+       for _, tt := range tests {
+               t.Run(tt.name, func(t *testing.T) {
+                       gotRes := HandleSetClientUserInfo(tt.args.cc, &tt.args.t)
+                       tranAssertEqual(t, tt.wantRes, gotRes)
+               })
+       }
+}
+
+func TestHandleDelNewsItem(t *testing.T) {
+       type args struct {
+               cc *ClientConn
+               t  Transaction
+       }
+       tests := []struct {
+               name    string
+               args    args
+               wantRes []Transaction
+       }{
+               {
+                       name: "when user does not have permission to delete a news category",
+                       args: args{
+                               cc: &ClientConn{
+                                       Account: &Account{
+                                               Access: accessBitmap{},
+                                       },
+                                       ID: [2]byte{0, 1},
+                                       Server: &Server{
+                                               ThreadedNews: &ThreadedNews{Categories: map[string]NewsCategoryListData15{
+                                                       "test": {
+                                                               Type: [2]byte{0, 3},
+                                                               Name: "zz",
+                                                       },
+                                               }},
+                                       },
+                               },
+                               t: NewTransaction(
+                                       TranDelNewsItem, [2]byte{},
+                                       NewField(FieldNewsPath,
+                                               []byte{
+                                                       0, 1,
+                                                       0, 0,
+                                                       4,
+                                                       0x74, 0x65, 0x73, 0x74,
+                                               },
+                                       ),
+                               ),
+                       },
+                       wantRes: []Transaction{
+                               {
+                                       clientID:  [2]byte{0, 1},
                                        IsReply:   0x01,
-                                       Type:      []byte{0, 0x79},
-                                       ID:        []byte{0, 0, 0, 0},
-                                       ErrorCode: []byte{0, 0, 0, 0},
-                                       Fields:    []Field{},
+                                       ErrorCode: [4]byte{0, 0, 0, 1},
+                                       Fields: []Field{
+                                               NewField(FieldError, []byte("You are not allowed to delete news categories.")),
+                                       },
+                               },
+                       },
+               },
+               {
+                       name: "when user does not have permission to delete a news folder",
+                       args: args{
+                               cc: &ClientConn{
+                                       Account: &Account{
+                                               Access: accessBitmap{},
+                                       },
+                                       ID: [2]byte{0, 1},
+                                       Server: &Server{
+                                               ThreadedNews: &ThreadedNews{Categories: map[string]NewsCategoryListData15{
+                                                       "testcat": {
+                                                               Type: [2]byte{0, 2},
+                                                               Name: "test",
+                                                       },
+                                               }},
+                                       },
+                               },
+                               t: NewTransaction(
+                                       TranDelNewsItem, [2]byte{},
+                                       NewField(FieldNewsPath,
+                                               []byte{
+                                                       0, 1,
+                                                       0, 0,
+                                                       4,
+                                                       0x74, 0x65, 0x73, 0x74,
+                                               },
+                                       ),
+                               ),
+                       },
+                       wantRes: []Transaction{
+                               {
+                                       clientID:  [2]byte{0, 1},
+                                       IsReply:   0x01,
+                                       ErrorCode: [4]byte{0, 0, 0, 1},
+                                       Fields: []Field{
+                                               NewField(FieldError, []byte("You are not allowed to delete news folders.")),
+                                       },
+                               },
+                       },
+               },
+               {
+                       name: "when user deletes a news folder",
+                       args: args{
+                               cc: &ClientConn{
+                                       Account: &Account{
+                                               Access: func() accessBitmap {
+                                                       var bits accessBitmap
+                                                       bits.Set(accessNewsDeleteFldr)
+                                                       return bits
+                                               }(),
+                                       },
+                                       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
+                                               }(),
+                                               ThreadedNews: &ThreadedNews{Categories: map[string]NewsCategoryListData15{
+                                                       "testcat": {
+                                                               Type: [2]byte{0, 2},
+                                                               Name: "test",
+                                                       },
+                                               }},
+                                       },
+                               },
+                               t: NewTransaction(
+                                       TranDelNewsItem, [2]byte{},
+                                       NewField(FieldNewsPath,
+                                               []byte{
+                                                       0, 1,
+                                                       0, 0,
+                                                       4,
+                                                       0x74, 0x65, 0x73, 0x74,
+                                               },
+                                       ),
+                               ),
+                       },
+                       wantRes: []Transaction{
+                               {
+                                       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 := HandleDelNewsItem(tt.args.cc, &tt.args.t)
+
+                       tranAssertEqual(t, tt.wantRes, gotRes)
+               })
+       }
+}
+
+func TestHandleTranOldPostNews(t *testing.T) {
+       type args struct {
+               cc *ClientConn
+               t  Transaction
+       }
+       tests := []struct {
+               name    string
+               args    args
+               wantRes []Transaction
+       }{
+               {
+                       name: "when user does not have required permission",
+                       args: args{
+                               cc: &ClientConn{
+                                       Account: &Account{
+                                               Access: func() accessBitmap {
+                                                       var bits accessBitmap
+                                                       return bits
+                                               }(),
+                                       },
+                               },
+                               t: NewTransaction(
+                                       TranOldPostNews, [2]byte{0, 1},
+                                       NewField(FieldData, []byte("hai")),
+                               ),
+                       },
+                       wantRes: []Transaction{
+                               {
+                                       IsReply:   0x01,
+                                       ErrorCode: [4]byte{0, 0, 0, 1},
+                                       Fields: []Field{
+                                               NewField(FieldError, []byte("You are not allowed to post news.")),
+                                       },
+                               },
+                       },
+               },
+               {
+                       name: "when user posts news update",
+                       args: args{
+                               cc: &ClientConn{
+                                       Account: &Account{
+                                               Access: func() accessBitmap {
+                                                       var bits accessBitmap
+                                                       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
+                                               }(),
+                                               ConfigDir: "/fakeConfigRoot",
+                                               Config:    &Config{},
+                                       },
+                               },
+                               t: NewTransaction(
+                                       TranOldPostNews, [2]byte{0, 1},
+                                       NewField(FieldData, []byte("hai")),
+                               ),
+                       },
+                       wantRes: []Transaction{
+                               {
+                                       IsReply: 0x01,
+                               },
+                       },
+               },
+       }
+       for _, tt := range tests {
+               t.Run(tt.name, func(t *testing.T) {
+                       gotRes := HandleTranOldPostNews(tt.args.cc, &tt.args.t)
+
                        tranAssertEqual(t, tt.wantRes, gotRes)
                })
        }
 }
+
+func TestHandleInviteNewChat(t *testing.T) {
+       type args struct {
+               cc *ClientConn
+               t  Transaction
+       }
+       tests := []struct {
+               name    string
+               args    args
+               wantRes []Transaction
+       }{
+               {
+                       name: "when user does not have required permission",
+                       args: args{
+                               cc: &ClientConn{
+                                       Account: &Account{
+                                               Access: func() accessBitmap {
+                                                       var bits accessBitmap
+                                                       return bits
+                                               }(),
+                                       },
+                               },
+                               t: NewTransaction(TranInviteNewChat, [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 request private chat.")),
+                                       },
+                               },
+                       },
+               },
+               {
+                       name: "when userA invites userB to new private chat",
+                       args: args{
+                               cc: &ClientConn{
+                                       ID: [2]byte{0, 1},
+                                       Account: &Account{
+                                               Access: func() accessBitmap {
+                                                       var bits accessBitmap
+                                                       bits.Set(accessOpenChat)
+                                                       return bits
+                                               }(),
+                                       },
+                                       UserName: []byte("UserA"),
+                                       Icon:     []byte{0, 1},
+                                       Flags:    [2]byte{0, 0},
+                                       Server: &Server{
+                                               Clients: map[[2]byte]*ClientConn{
+                                                       [2]byte{0, 2}: {
+                                                               ID:       [2]byte{0, 2},
+                                                               UserName: []byte("UserB"),
+                                                       },
+                                               },
+                                               PrivateChats: make(map[[4]byte]*PrivateChat),
+                                       },
+                               },
+                               t: NewTransaction(
+                                       TranInviteNewChat, [2]byte{0, 1},
+                                       NewField(FieldUserID, []byte{0, 2}),
+                               ),
+                       },
+                       wantRes: []Transaction{
+                               {
+                                       clientID: [2]byte{0, 2},
+                                       Type:     [2]byte{0, 0x71},
+                                       Fields: []Field{
+                                               NewField(FieldChatID, []byte{0x52, 0xfd, 0xfc, 0x07}),
+                                               NewField(FieldUserName, []byte("UserA")),
+                                               NewField(FieldUserID, []byte{0, 1}),
+                                       },
+                               },
+
+                               {
+                                       clientID: [2]byte{0, 1},
+                                       IsReply:  0x01,
+                                       Fields: []Field{
+                                               NewField(FieldChatID, []byte{0x52, 0xfd, 0xfc, 0x07}),
+                                               NewField(FieldUserName, []byte("UserA")),
+                                               NewField(FieldUserID, []byte{0, 1}),
+                                               NewField(FieldUserIconID, []byte{0, 1}),
+                                               NewField(FieldUserFlags, []byte{0, 0}),
+                                       },
+                               },
+                       },
+               },
+               {
+                       name: "when userA invites userB to new private chat, but UserB has refuse private chat enabled",
+                       args: args{
+                               cc: &ClientConn{
+                                       ID: [2]byte{0, 1},
+                                       Account: &Account{
+                                               Access: func() accessBitmap {
+                                                       var bits accessBitmap
+                                                       bits.Set(accessOpenChat)
+                                                       return bits
+                                               }(),
+                                       },
+                                       UserName: []byte("UserA"),
+                                       Icon:     []byte{0, 1},
+                                       Flags:    [2]byte{0, 0},
+                                       Server: &Server{
+                                               Clients: map[[2]byte]*ClientConn{
+                                                       [2]byte{0, 2}: {
+                                                               ID:       [2]byte{0, 2},
+                                                               UserName: []byte("UserB"),
+                                                               Flags:    [2]byte{255, 255},
+                                                       },
+                                               },
+                                               PrivateChats: make(map[[4]byte]*PrivateChat),
+                                       },
+                               },
+                               t: NewTransaction(
+                                       TranInviteNewChat, [2]byte{0, 1},
+                                       NewField(FieldUserID, []byte{0, 2}),
+                               ),
+                       },
+                       wantRes: []Transaction{
+                               {
+                                       clientID: [2]byte{0, 1},
+                                       Type:     [2]byte{0, 0x68},
+                                       Fields: []Field{
+                                               NewField(FieldData, []byte("UserB does not accept private chats.")),
+                                               NewField(FieldUserName, []byte("UserB")),
+                                               NewField(FieldUserID, []byte{0, 2}),
+                                               NewField(FieldOptions, []byte{0, 2}),
+                                       },
+                               },
+                               {
+                                       clientID: [2]byte{0, 1},
+                                       IsReply:  0x01,
+                                       Fields: []Field{
+                                               NewField(FieldChatID, []byte{0x52, 0xfd, 0xfc, 0x07}),
+                                               NewField(FieldUserName, []byte("UserA")),
+                                               NewField(FieldUserID, []byte{0, 1}),
+                                               NewField(FieldUserIconID, []byte{0, 1}),
+                                               NewField(FieldUserFlags, []byte{0, 0}),
+                                       },
+                               },
+                       },
+               },
+       }
+       for _, tt := range tests {
+               t.Run(tt.name, func(t *testing.T) {
+                       gotRes := HandleInviteNewChat(tt.args.cc, &tt.args.t)
+
+                       tranAssertEqual(t, tt.wantRes, gotRes)
+               })
+       }
+}
+
+func TestHandleGetNewsArtData(t *testing.T) {
+       type args struct {
+               cc *ClientConn
+               t  Transaction
+       }
+       tests := []struct {
+               name    string
+               args    args
+               wantRes []Transaction
+       }{
+               {
+                       name: "when user does not have required permission",
+                       args: args{
+                               cc: &ClientConn{
+                                       Account: &Account{
+                                               Access: func() accessBitmap {
+                                                       var bits accessBitmap
+                                                       return bits
+                                               }(),
+                                       },
+                                       Server: &Server{
+                                               Accounts: map[string]*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.")),
+                                       },
+                               },
+                       },
+               },
+       }
+       for _, tt := range tests {
+               t.Run(tt.name, func(t *testing.T) {
+                       gotRes := HandleGetNewsArtData(tt.args.cc, &tt.args.t)
+                       tranAssertEqual(t, tt.wantRes, gotRes)
+               })
+       }
+}
+
+func TestHandleGetNewsArtNameList(t *testing.T) {
+       type args struct {
+               cc *ClientConn
+               t  Transaction
+       }
+       tests := []struct {
+               name    string
+               args    args
+               wantRes []Transaction
+       }{
+               {
+                       name: "when user does not have required permission",
+                       args: args{
+                               cc: &ClientConn{
+                                       Account: &Account{
+                                               Access: func() accessBitmap {
+                                                       var bits accessBitmap
+                                                       return bits
+                                               }(),
+                                       },
+                                       Server: &Server{
+                                               Accounts: map[string]*Account{},
+                                       },
+                               },
+                               t: NewTransaction(
+                                       TranGetNewsArtNameList, [2]byte{0, 1},
+                               ),
+                       },
+                       wantRes: []Transaction{
+                               {
+                                       Flags:     0x00,
+                                       IsReply:   0x01,
+                                       Type:      [2]byte{0, 0},
+                                       ErrorCode: [4]byte{0, 0, 0, 1},
+                                       Fields: []Field{
+                                               NewField(FieldError, []byte("You are not allowed to read news.")),
+                                       },
+                               },
+                       },
+               },
+               {
+                       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,
+                                       [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 := HandleGetNewsArtNameList(tt.args.cc, &tt.args.t)
+
+                       tranAssertEqual(t, tt.wantRes, gotRes)
+               })
+       }
+}
+
+func TestHandleNewNewsFldr(t *testing.T) {
+       type args struct {
+               cc *ClientConn
+               t  Transaction
+       }
+       tests := []struct {
+               name    string
+               args    args
+               wantRes []Transaction
+       }{
+               {
+                       name: "when user does not have required permission",
+                       args: args{
+                               cc: &ClientConn{
+                                       Account: &Account{
+                                               Access: func() accessBitmap {
+                                                       var bits accessBitmap
+                                                       return bits
+                                               }(),
+                                       },
+                                       Server: &Server{
+                                               Accounts: map[string]*Account{},
+                                       },
+                               },
+                               t: NewTransaction(
+                                       TranGetNewsArtNameList, [2]byte{0, 1},
+                               ),
+                       },
+                       wantRes: []Transaction{
+                               {
+                                       Flags:     0x00,
+                                       IsReply:   0x01,
+                                       Type:      [2]byte{0, 0},
+                                       ErrorCode: [4]byte{0, 0, 0, 1},
+                                       Fields: []Field{
+                                               NewField(FieldError, []byte("You are not allowed to create news folders.")),
+                                       },
+                               },
+                       },
+               },
+               {
+                       name: "with a valid request",
+                       args: args{
+                               cc: &ClientConn{
+                                       Account: &Account{
+                                               Access: func() accessBitmap {
+                                                       var bits accessBitmap
+                                                       bits.Set(accessNewsCreateFldr)
+                                                       return bits
+                                               }(),
+                                       },
+                                       logger: NewTestLogger(),
+                                       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
+                                               }(),
+                                               ThreadedNews: &ThreadedNews{Categories: map[string]NewsCategoryListData15{
+                                                       "test": {
+                                                               Type:    [2]byte{0, 2},
+                                                               Name:    "test",
+                                                               SubCats: make(map[string]NewsCategoryListData15),
+                                                       },
+                                               }},
+                                       },
+                               },
+                               t: NewTransaction(
+                                       TranGetNewsArtNameList, [2]byte{0, 1},
+                                       NewField(FieldFileName, []byte("testFolder")),
+                                       NewField(FieldNewsPath,
+                                               []byte{
+                                                       0, 1,
+                                                       0, 0,
+                                                       4,
+                                                       0x74, 0x65, 0x73, 0x74,
+                                               },
+                                       ),
+                               ),
+                       },
+                       wantRes: []Transaction{
+                               {
+                                       clientID: [2]byte{0, 1},
+                                       IsReply:  0x01,
+                                       Fields:   []Field{},
+                               },
+                       },
+               },
+               //{
+               //      Name: "when there is an error writing the threaded news file",
+               //      args: args{
+               //              cc: &ClientConn{
+               //                      Account: &Account{
+               //                              Access: func() accessBitmap {
+               //                                      var bits accessBitmap
+               //                                      bits.Set(accessNewsCreateFldr)
+               //                                      return bits
+               //                              }(),
+               //                      },
+               //                      logger: NewTestLogger(),
+               //                      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(os.ErrNotExist)
+               //                                      return mfs
+               //                              }(),
+               //                              ThreadedNews: &ThreadedNews{Categories: map[string]NewsCategoryListData15{
+               //                                      "test": {
+               //                                              Type:     []byte{0, 2},
+               //                                              Count:    nil,
+               //                                              NameSize: 0,
+               //                                              Name:     "test",
+               //                                              SubCats:  make(map[string]NewsCategoryListData15),
+               //                                      },
+               //                              }},
+               //                      },
+               //              },
+               //              t: NewTransaction(
+               //                      TranGetNewsArtNameList, [2]byte{0, 1},
+               //                      NewField(FieldFileName, []byte("testFolder")),
+               //                      NewField(FieldNewsPath,
+               //                              []byte{
+               //                                      0, 1,
+               //                                      0, 0,
+               //                                      4,
+               //                                      0x74, 0x65, 0x73, 0x74,
+               //                              },
+               //                      ),
+               //              ),
+               //      },
+               //      wantRes: []Transaction{
+               //              {
+               //                      clientID:  [2]byte{0, 1},
+               //                      Flags:     0x00,
+               //                      IsReply:   0x01,
+               //                      Type:      [2]byte{0, 0},
+               //                      ErrorCode: [4]byte{0, 0, 0, 1},
+               //                      Fields: []Field{
+               //                              NewField(FieldError, []byte("Error creating news folder.")),
+               //                      },
+               //              },
+               //      },
+       }
+       for _, tt := range tests {
+               t.Run(tt.name, func(t *testing.T) {
+                       gotRes := HandleNewNewsFldr(tt.args.cc, &tt.args.t)
+
+                       tranAssertEqual(t, tt.wantRes, gotRes)
+               })
+       }
+}
+
+func TestHandleDownloadBanner(t *testing.T) {
+       type args struct {
+               cc *ClientConn
+               t  Transaction
+       }
+       tests := []struct {
+               name    string
+               args    args
+               wantRes []Transaction
+       }{
+               // TODO: Add test cases.
+       }
+       for _, tt := range tests {
+               t.Run(tt.name, func(t *testing.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{
+                                               FS: func() *MockFileStore {
+                                                       mfs := &MockFileStore{}
+                                                       mfs.On("WriteFile", "ThreadedNews.yaml", mock.Anything, mock.Anything).Return(nil, os.ErrNotExist)
+                                                       return mfs
+                                               }(),
+                                               mux:             sync.Mutex{},
+                                               threadedNewsMux: sync.Mutex{},
+                                               ThreadedNews: &ThreadedNews{
+                                                       Categories: map[string]NewsCategoryListData15{
+                                                               "www": {
+                                                                       Type:       [2]byte{},
+                                                                       Name:       "www",
+                                                                       Articles:   map[uint32]*NewsArtData{},
+                                                                       SubCats:    nil,
+                                                                       GUID:       [16]byte{},
+                                                                       AddSN:      [4]byte{},
+                                                                       DeleteSN:   [4]byte{},
+                                                                       readOffset: 0,
+                                                               },
+                                                       },
+                                               },
+                                       },
+                                       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))
+               })
+       }
+}