fixed a bug on up/down check and added tests for it