Refactor the integration tests
Add a test for #939
Fix median crash on null values or non integer values

Fix #939