Improve code. Add test.