refactor logic classes and improve tests