Fixing stuff; adding tests