made things a bit more testable and cleaner

Signed-off-by: Daniel Fagnan <dnfagnan@gmail.com>