refactor test code to separate file, tests work now and detect ERROR