add unit tests to detect bugs like 2602203524bc1cc21684a37eca7ca8a3a0838f3a