Added test cases and fixed a compiler warning.