Added test, fixed minor bug