Tests and most of the logic layer