First commit
add first tests, fix some bugs found in test