resolving errors and adding some tests