refacotring + more tests