#13 Adding more tests and improving implementation