wrote tests
fixed bug