Move startup functionality into main() for testability