[fix][test] Added unit test for registering file descriptor

In addition fixed one memory leak problem and removed handle paramater
from the register_fd function.