Modularize
Fix tests