Improve tests, add expected value and variance functions