added test case for issue 22 and optimised BETWEEN handling