Add helpers and improve testcase.

Signed-off-by: crynobone <crynobone@gmail.com>