Rearranging headers for less coding

Signed-off-by: Shahbaz Youssefi <ShabbyX@gmail.com>
Added thread test

Signed-off-by: Shahbaz Youssefi <ShabbyX@gmail.com>