restructure and tests