Added more unittest-friendly main method.