Added test case; minor bugfix