[update] refactor common parts in test Makefiles

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