major refactor for proper testing