Added tests, renamed some variables