Writing tests for to_binary