fixed bug, added test