cleaning code; improved tests coverage