add test for bimodal solution and refactor code