moved into helper file, and added more tests