added test, fixed bug