Minor bug fixes, added test classes