improved test coverage and fixed some minor issues