Added basic test and fixed bugs