fixes and added a test