New unit tests added and some bug fixes made