Fixed small issues and improved test code.