started adding unit tests
fixed some bugs