lifted out tests from main program, much cleaner now