added specs for more than 70% code coverage, fixed some small bugs identified through the tests