Added test and minor fix