move test logic from main() in order to prevent pasting the same code 10 different times :)