Minor changes
Add W computation code
Add tests for W computation