Added test class; bug fix