adding more unit tests and fixing bugs