diff --git a/fanotify_api.go b/fanotify_api.go
index d812922..b571efd 100644
--- a/fanotify_api.go
+++ b/fanotify_api.go
@@ -38,7 +38,7 @@ type Event struct {
 	// Mask holds bit mask representing the operation
 	Mask Action
 	// Pid Process ID of the process that caused the event
-	Pid int32
+	Pid int
 }
 
 // Listener represents a fanotify notification group that holds a list of files,
diff --git a/fanotify_event.go b/fanotify_event.go
index cb591de..2727442 100644
--- a/fanotify_event.go
+++ b/fanotify_event.go
@@ -353,11 +353,15 @@ func (l *Listener) readEvents() error {
 					metadata = (*unix.FanotifyEventMetadata)(unsafe.Pointer(&buf[i]))
 					continue
 				}
+				mask := metadata.Mask
+				if mask&unix.FAN_ONDIR == unix.FAN_ONDIR {
+					mask = mask ^ unix.FAN_ONDIR
+				}
 				event := Event{
 					Fd:   int(metadata.Fd),
 					Path: string(name[:n1]),
-					Mask: Action(metadata.Mask),
-					Pid:  metadata.Pid,
+					Mask: Action(mask),
+					Pid:  int(metadata.Pid),
 				}
 				l.Events <- event
 
@@ -395,12 +399,16 @@ func (l *Listener) readEvents() error {
 				fdPath := fmt.Sprintf("/proc/self/fd/%d", fd)
 				n1, _ := unix.Readlink(fdPath, name[:]) // TODO handle err case
 				pathName := string(name[:n1])
+				mask := metadata.Mask
+				if mask&unix.FAN_ONDIR == unix.FAN_ONDIR {
+					mask = mask ^ unix.FAN_ONDIR
+				}
 				event := Event{
 					Fd:       fd,
 					Path:     pathName,
 					FileName: fileName,
-					Mask:     Action(metadata.Mask),
-					Pid:      metadata.Pid,
+					Mask:     Action(mask),
+					Pid:      int(metadata.Pid),
 				}
 				l.Events <- event
 				i += int(metadata.Event_len)
diff --git a/fanotify_test.go b/fanotify_test.go
index 7eb234a..c31d851 100644
--- a/fanotify_test.go
+++ b/fanotify_test.go
@@ -2,7 +2,11 @@ package fanotify
 
 import (
 	"errors"
+	"fmt"
+	"os"
+	"os/exec"
 	"testing"
+	"time"
 
 	"github.com/stretchr/testify/assert"
 	"golang.org/x/sys/unix"
@@ -31,18 +35,95 @@ func TestNewListenerInvalidFlagPreClassContent(t *testing.T) {
 func TestNewListenerValidFlags(t *testing.T) {
 	var flags uint
 	var eventFlags uint
-
 	flags = unix.FAN_CLASS_NOTIF | unix.FAN_REPORT_FID
+	eventFlags = unix.O_RDONLY | unix.O_LARGEFILE | unix.O_CLOEXEC
 	l, err := newListener("/", flags, eventFlags, 4096)
 	assert.Nil(t, err)
 	assert.NotNil(t, l)
 }
 
-// skipped
-func testKernelVersion(t *testing.T) {
-	maj, min, patch, err := kernelVersion()
-	assert.Equal(t, maj, 5)
-	assert.Equal(t, min, 15)
-	assert.Equal(t, patch, 0)
+// func testKernelVersion(t *testing.T) {
+// 	maj, min, patch, err := kernelVersion()
+// 	assert.Equal(t, maj, 5)
+// 	assert.Equal(t, min, 15)
+// 	assert.Equal(t, patch, 0)
+// 	assert.Nil(t, err)
+// }
+
+func catFile(filename string) (int, error) {
+	cmd := exec.Command("cat", filename)
+	err := cmd.Run()
+	if err != nil {
+		return 0, err
+	}
+	return cmd.Process.Pid, nil
+}
+
+func modifyFile(filename string) (int, error) {
+	cmd := exec.Command("touch", "-m", filename)
+	err := cmd.Run()
+	if err != nil {
+		return 0, err
+	}
+	return cmd.Process.Pid, nil
+}
+
+// TestWithCapSysAdmFanotifyFileAccessed requires CAP_SYS_ADM privilege.
+func TestWithCapSysAdmFanotifyFileAccessed(t *testing.T) {
+	l, err := NewListener("/", 4096, true)
+	assert.Nil(t, err)
+	assert.NotNil(t, l)
+	watchDir := t.TempDir()
+	t.Logf("Watch Directory: %s", watchDir)
+	action := FileOrDirectoryAccessed
+	l.AddWatch(watchDir, action)
+	go l.Start()
+	defer l.Stop()
+	// generate event
+	data := []byte("test data...")
+	testFile := fmt.Sprintf("%s/test.dat", watchDir)
+	err = os.WriteFile(testFile, data, 0666)
+	assert.Nil(t, err)
+	t.Logf("Test file created %s", testFile)
+	pid, err := catFile(testFile)
+	assert.Nil(t, err)
+	select {
+	case <-time.After(100 * time.Millisecond):
+		t.Error("Timeout Error: FileOrDirectoryAccessed event not received")
+	case event := <-l.Events:
+		assert.Equal(t, fmt.Sprintf("%s/%s", event.Path, event.FileName), testFile)
+		assert.Equal(t, event.Pid, pid)
+		hasFileAccessed := (event.Mask & FileAccessed) == FileAccessed
+		assert.True(t, hasFileAccessed)
+	}
+}
+
+// TestWithCapSysAdmFanotifyFileModified requires CAP_SYS_ADM privilege.
+func TestWithCapSysAdmFanotifyFileModified(t *testing.T) {
+	l, err := NewListener("/", 4096, true)
+	assert.Nil(t, err)
+	assert.NotNil(t, l)
+	watchDir := t.TempDir()
+	t.Logf("Watch Directory: %s", watchDir)
+	action := FileModified
+	l.AddWatch(watchDir, action)
+	go l.Start()
+	defer l.Stop()
+	// generate event
+	data := []byte("test data...")
+	testFile := fmt.Sprintf("%s/test.dat", watchDir)
+	err = os.WriteFile(testFile, data, 0666)
+	assert.Nil(t, err)
+	t.Logf("Test file created %s", testFile)
+	pid, err := modifyFile(testFile)
 	assert.Nil(t, err)
+	select {
+	case <-time.After(100 * time.Millisecond):
+		t.Error("Timeout Error: FileOrDirectoryAccessed event not received")
+	case event := <-l.Events:
+		assert.Equal(t, fmt.Sprintf("%s/%s", event.Path, event.FileName), testFile)
+		assert.Equal(t, event.Pid, pid)
+		isModifed := (event.Mask & FileModified) == FileModified
+		assert.True(t, isModifed)
+	}
 }
